HexSticker
:sparkles: Hexagon sticker in R
Install / Use
/learn @GuangchuangYu/HexStickerREADME
hexSticker: create hexagon sticker in R
:writing_hand: Author
Guangchuang YU https://yulab-smu.top
School of Basic Medical Sciences, Southern Medical University
:arrow_double_down: Installation
Install the hexSticker package via CRAN:
install.packages("hexSticker")
You can also install the package via the Github repository.
# install.package("remotes") #In case you have not installed it.
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.
brew update && brew install homebrew/cask/xquartz
Examples
stickerfunction will produce a file with dimension exactly for printing according to http://hexb.in/sticker.html
base plot
library(hexSticker)
s <- sticker(~plot(cars, cex=.5, cex.axis=.5, mgp=c(0,.3,0), xlab="", ylab=""),
package="hexSticker", p_size=20, s_x=.8, s_y=.6, s_width=1.4, s_height=1.2,
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
library(lattice)
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
bwplot <- bwplot(counts ~ outcome | treatment, xlab=NULL, ylab=NULL, cex=.5,
scales=list(cex=.5), par.strip.text=list(cex=.5))
sticker(bwplot, package="hexSticker", p_size=20, s_x=1.05, s_y=.8, s_width=2, s_height=1.5,
h_fill="#f9690e", h_color="#f39c12", filename="inst/figures/lattice.png")
<img src="inst/figures/lattice.png" height="300"/>
ggplot2
library(ggplot2)
p <- ggplot(aes(x = mpg, y = wt), data = mtcars) + geom_point()
p <- p + theme_void() + theme_transparent()
sticker(p, package="hexSticker", p_size=20, s_x=1, s_y=.75, s_width=1.3, s_height=1,
filename="inst/figures/ggplot2.png")
<img src="inst/figures/ggplot2.png" height="300"/>
image file
imgurl <- system.file("figures/cat.png", package="hexSticker")
sticker(imgurl, package="hexSticker", p_size=20, s_x=1, s_y=.75, s_width=.6,
filename="inst/figures/imgfile.png")
<img src="inst/figures/imgfile.png" height="300"/>
Google fonts
library(showtext)
## Loading Google fonts (http://www.google.com/fonts)
font_add_google("Gochi Hand", "gochi")
## Automatically use showtext to render text for future devices
showtext_auto()
## use the ggplot2 example
sticker(p, package="hexSticker", p_size=22, s_x=1, s_y=.75, s_width=1.3, s_height=1,
p_family = "gochi", filename="inst/figures/ggplot2-google-font.png")
<img src="inst/figures/ggplot2-google-font.png" height="300"/>
:sparkling_heart: Stickers produced by hexSticker
If you use
hexStickerand want your sticker to be listed here, please feel free to edit README.Rmd, and runrmarkdown::render("README.Rmd", rmarkdown::md_document(variant = "gfm"))inRto generateREADME.md.
Please put stickers in alphabet order.
Stickers for software packages
<!-- [<img src="" height="120"/>]() --><img src="https://raw.githubusercontent.com/furrer-lab/abn/refs/heads/main/inst/figures/logo.png" height="120"/> <img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/AnnotationFilter/AnnotationFilter_hl.png" height="120"/> <img src="https://github.com/lpantano/bcbioSmallRna/raw/master/inst/sticker/bcbioSmallRna.png" height="120"/> <img src="https://raw.githubusercontent.com/bcgov/bcmaps/master/inst/sticker/bcmaps.png" height="120"/> <img src="https://raw.githubusercontent.com/danielmarcelino/CamaraBR/master/inst/figures/CamaraBR-logo.png" height="120"/> <img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/ChIPseeker/ChIPseeker.png" height="120"/> <img src="https://github.com/le-huynh/chva.extras/blob/master/man/figures/logo.png?raw=true" height="120"/> <img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/cleaver/cleaver.png" height="120"/> <img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/clusterProfiler/clusterProfiler.png" height="120"/> <img src="https://raw.githubusercontent.com/SGS2000/ClustMC/master/man/figures/logo.png" height="120"/> <img src="https://raw.githubusercontent.com/stevecondylios/collidr/master/man/figures/collidr.png" height="120"/> <img src="https://github.com/RhoInc/CRANsearcher/raw/master/inst/image/hex/CRANsearcher_hexSticker.png" height="120"/> <img src="https://github.com/sstoeckl/crypto2/raw/master/man/figures/crypto2_hex.png" height="120"/> <img src="https://raw.githubusercontent.com/nathansam/datefixR/main/man/figures/sticker.png " height="120"/> <img src="https://raw.githubusercontent.com/eikeluedeling/decisionSupport/master/vignettes/decisionSupport.png" height="120"/> <img src="https://raw.githubusercontent.com/lpantano/DEGreport/main/inst/sticker/degreport.png" height="120"/> <img src="https://raw.githubusercontent.com/villegar/dive/master/inst/images/logo.png" height="120"/> <img src="https://github.com/tbradley1013/dragondown/raw/master/man/figures/dragondown.png" height="120"/> <img src="https://github.com/calcita/ech/blob/master/man/figures/ech_logo.png" height="120"/> <img src="https://github.com/mrchypark/elbird/raw/main/man/figures/logo.png" height="120"/> <img src="https://raw.githubusercontent.com/lance-waller-lab/envi/main/man/figures/envi.png" height="120"/> <img src="https://raw.githubusercontent.com/asilatakarandikar/eparlibscrapR/main/man/figures/logo.png" height="120"/> <img src="https://raw.githubusercontent.com/CWWhitney/ethnobotanyR/master/vignettes/ethnobotanyR.png" height="120"/> <img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/FamAgg/FamAgg_hl.png" height="120"/> <img src="https://github.com/lschneiderbauer/fCWTr/raw/master/man/figures/logo.svg" height="120"/> <img src="https://github.com/sstoeckl/ffdownload/raw/master/man/figures/logo.png" height="120"/> <img src="https://github.com/wangjiaxuan666/fixbatch/blob/main/man/figures/fixbatch_hexSticker.png" height="120"/> <img src="https://raw.githubusercontent.com/JeffreyRStevens/flashr/main/man/figures/logo.png" height="120"/> <img src="https://raw.githubusercontent.com/lance-waller-lab/gateR/main/man/figures/gateR.png" height="120"/> <img src="https://raw.githubusercontent.com/Matheusbp/GemirTools/master/man/figures/logo.png" height="120"/> <img src="https://github.com/ipeaGIT/geobr/raw/master/r-package/man/figures/geobr_logo_b.png" height="120"/> <img src="https://github.com/RichDeto/geouy/blob/master/man/figures/geouy_logo_b.png" height="120"/> <img src="https://www.samabbott.co.uk/getTBinR/reference/figures/logo.png" height="120"/> <img src="https://raw.githubusercontent.com/ejade42/ggDNAvis/main/man/figures/logo.png" height="120"/> [<img src="https://raw.githubusercontent.com/strengejacke/ggeffects/master/man/figures/logo.png" height="12
