项目作者: GuangchuangYu

项目描述 :
:闪光:R中的六角形贴纸
高级语言: R
项目地址: git://github.com/GuangchuangYu/hexSticker.git
创建时间: 2017-03-13T03:23:54Z
项目社区:https://github.com/GuangchuangYu/hexSticker

开源协议:

下载


hexSticker: create hexagon sticker in R

CRAN_Status_Badge


:writing_hand: Author

Guangchuang YU https://yulab-smu.top

School of Basic Medical Sciences, Southern Medical University

saythanks


:arrow_double_down: Installation

Install the hexSticker package via CRAN:

  1. install.packages("hexSticker")

You can also install the package via the Github repository.

  1. # install.package("remotes") #In case you have not installed it.
  2. remotes::install_github("GuangchuangYu/hexSticker")

Fail to install

imageMagick

imageMagick is required for installing hexSticker. If you have not
installed it, please try the following
approaches.

Fail to load ‘sysfonts’

In Mac OS, you may need to re-install sysfont to properly load it.

Be sure to install xquartz first.

  1. brew update && brew install homebrew/cask/xquartz

Examples

sticker function will produce a file with dimension exactly for
printing according to http://hexb.in/sticker.html

base plot

  1. library(hexSticker)
  2. s <- sticker(~plot(cars, cex=.5, cex.axis=.5, mgp=c(0,.3,0), xlab="", ylab=""),
  3. package="hexSticker", p_size=20, s_x=.8, s_y=.6, s_width=1.4, s_height=1.2,
  4. filename="inst/figures/baseplot.png")

The sticker() will generate a figure specified by the filename
parameter. The output of the sticker() function is a ggplot object,
e.g. the s variable in the above example. Print the object,
print(s), will display the image. However, the image may slightly
different from the created image file since the graphic device size are
different. To solve this issue, hexSticker package provides plot
function to preview sticker. Try plot(s) :).

lattice

  1. library(lattice)
  2. counts <- c(18,17,15,20,10,20,25,13,12)
  3. outcome <- gl(3,1,9)
  4. treatment <- gl(3,3)
  5. bwplot <- bwplot(counts ~ outcome | treatment, xlab=NULL, ylab=NULL, cex=.5,
  6. scales=list(cex=.5), par.strip.text=list(cex=.5))
  7. sticker(bwplot, package="hexSticker", p_size=20, s_x=1.05, s_y=.8, s_width=2, s_height=1.5,
  8. h_fill="#f9690e", h_color="#f39c12", filename="inst/figures/lattice.png")

ggplot2

  1. library(ggplot2)
  2. p <- ggplot(aes(x = mpg, y = wt), data = mtcars) + geom_point()
  3. p <- p + theme_void() + theme_transparent()
  4. sticker(p, package="hexSticker", p_size=20, s_x=1, s_y=.75, s_width=1.3, s_height=1,
  5. filename="inst/figures/ggplot2.png")

image file

  1. imgurl <- system.file("figures/cat.png", package="hexSticker")
  2. sticker(imgurl, package="hexSticker", p_size=20, s_x=1, s_y=.75, s_width=.6,
  3. filename="inst/figures/imgfile.png")

Google fonts

  1. library(showtext)
  2. ## Loading Google fonts (http://www.google.com/fonts)
  3. font_add_google("Gochi Hand", "gochi")
  4. ## Automatically use showtext to render text for future devices
  5. showtext_auto()
  6. ## use the ggplot2 example
  7. sticker(p, package="hexSticker", p_size=22, s_x=1, s_y=.75, s_width=1.3, s_height=1,
  8. p_family = "gochi", filename="inst/figures/ggplot2-google-font.png")


:sparkling_heart: Stickers produced by hexSticker

If you use hexSticker and want your sticker to be listed here,
please feel free to edit
README.Rmd,
and run
rmarkdown::render("README.Rmd", rmarkdown::md_document(variant = "gfm"))
in R to generate README.md.

Please put stickers in alphabet order.

Stickers for software packages


































































































































Stickers for events/workshops



Stickers for fun


Stickers for organizations





Print/order stickers

Sticker designers can make their stickers available via Sticker
Mule
.

  • badger: Query information
    and generate badge for using in README and GitHub Pages.
  • ggimage: Supports image
    files and graphic objects to be visualized in ‘ggplot2’ graphic
    system.
  • meme: Create Meme.
  • shadowtext: Create
    text grob with background shadow.