GithubHelp home page GithubHelp logo

hexsticker's Introduction

hexSticker: create hexagon sticker in R

CRAN_Status_Badge

✍️ Author

Guangchuang YU https://yulab-smu.top

School of Basic Medical Sciences, Southern Medical University

saythanks


⏬ 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

sticker function 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")

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")

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")

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")


💖 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") 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.

Related Tools

  • 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.

hexsticker's People

Contributors

adafede avatar ardiad avatar bohdan-khomtchouk avatar botan avatar cosimameyer avatar cwimpy avatar dieghernan avatar ellessenne avatar guangchuangyu avatar matt-int avatar mirkosignorelli avatar mrchypark avatar pdrhlik avatar plyush1993 avatar potterzot avatar prdm0 avatar qihongchao avatar rafalopespx avatar rcorty avatar richdeto avatar rrrlw avatar seabbs avatar shanmdphd avatar statsgary avatar steffenmoritz avatar stevecondylios avatar tbradley1013 avatar villegar avatar vlucet avatar wenlong-liu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hexsticker's Issues

Problem with example

Hi,
When I try to run the examples, I get this error message.
What should I do ?
Thanks in advance


  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")
Error in UseMethod("validGrob") : 
  no applicable method for 'validGrob' applied to an object of class "NULL"
In addition: Warning messages:
1: Using ragg device as default. Ignoring `type` and `antialias` arguments 
2: In editThisGrob(grob, specs) : slot 'vp' not found
3: In editThisGrob(grob, specs) : slot 'name' not found 

Unable to create sticker

When running the example plots from the readme I get the following error:

> sticker(expression(plot(cars)), package="hexSticker", p_size=8, s_x=1, s_y=.85, s_width=.5, s_height=.4, filename="test.png")
Error in mainview$data[, aes_x] : incorrect number of dimensions

Any ideas?

My sessionInfo:

> sessionInfo()
R Under development (unstable) (2017-01-19 r72014)
Platform: x86_64-apple-darwin16.4.0/x86_64 (64-bit)
Running under: macOS Sierra 10.12.4

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] hexSticker_0.0.1 png_0.1-7        ggplot2_2.2.1   

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9        magrittr_1.5       sysfonts_0.5       units_0.4-2       
 [5] MASS_7.3-45        munsell_0.4.3      colorspace_1.3-2   ape_4.1           
 [9] lattice_0.20-34    R6_2.2.0           showtextdb_1.0     udunits2_0.13     
[13] plyr_1.8.4         dplyr_0.5.0        tools_3.4.0        parallel_3.4.0    
[17] ggtree_1.7.9       gtable_0.2.0       nlme_3.1-131       ggforce_0.1.1     
[21] DBI_0.6            gridGraphics_0.1-5 lazyeval_0.2.0     assertthat_0.1    
[25] tibble_1.2         treeio_0.99.10     tidyr_0.6.1        tweenr_0.1.5      
[29] labeling_0.3       compiler_3.4.0     scales_0.4.1       showtext_0.4-6    
[33] jsonlite_1.3      

MSnbase sticker with hexSticker

Using the mz trellis object produced in MSnbase_sticker.R:

> undebug(sticker)
> sticker(mz, package = "MSnbase")
Error in mainview$data[, aes_x] : incorrect number of dimensions

Select font typeface

Would be nice if it was not only possible to select the font family (p_family) but also the font typeface (e.g. Lt, Rg) etc. or directly select the font e.g. p_font = "Aller_Lt".

h_size > 3 (large hexagon border thickness) crops off hexagon points

Aesthetically, I was after some thicker hexagon borders. However, it appears that thicker borders are cropped off from the top and bottom. Should the border grow internally instead of externally to prevent?

Here is example code:

imgurl <- system.file("figures/cat.png", package="hexSticker")
s<-sticker(imgurl, package="hexSticker", p_size=14, s_x=1, s_y=.75, s_width=.6, h_size=5,
         filename="imgfile.png")
# printing sticker
 s

I am doing an "Export" -> "Save As Image" from RStudio "Plots" panel:

Top and bottom points are clipped:
Rplot06

version 0.1.0

ggtree::subview now moved to ggimage::geom_subview and ggtree::theme_transparent move to ggimage::theme_transparent.

The width and height are now not proportion to the plot, but in native unit.

Here is an example:

library(ggimage)
d=tibble::data_frame(x=1:3, y=1:3, z=LETTERS[1:3])
d$bar = lapply(1:nrow(d), function(i) ggplot(d[i,], aes(z, y)) + geom_col())
ggplot() + xlim(0, 4) + ylim(0,4) + geom_subview(d$bar, x=d$x, y=d$y, width=1, height=1)

screen shot 2017-03-21 at 2 25 00 pm

Sorry for changing the unit and break your codes again. 😂

In this new version, I have split the sticker function to several layer.

Now we can use the following command to generate sticker:

ggplot() + geom_hexagon() + geom_subview() + geom_pkgname() + theme_sticker()

hexagon is a short cut for ggplot() + geom_hexagon() + theme_sticker().

see 9828a78.

@lgatto @jotsetung

please describe parameter ranges in more detail in sticker.Rd

A nice & potentially useful package, but w/o more detailed description of the parameters and their ranges, one is left to guess what they might be, and then iterate to find something that works.

p_x, p_y, s_x, s_y, s_height, s_width, ... ? What is the frame of reference for *_x., *_y positions? What is the relation of *_height, *_width to this?

Typo in README

Hi,

though I am not a native speaking English, I would like to let you know about a possible typo in the README:

The sticker() will generate a figure specify by the filename parameter.

Shouldn't it be:
The sticker() will generate a figure specified by the filename parameter. ?

Thanks for this very interesting package!
Damiano

Error when trying to create an "empty" sticker (only with package name)

I'm trying to come up with a minimalist hex sticker, but I'm having some problems when creating an empty sticker (i.e. that contains just the package name). The first time I try to create it using sticker() it works fine, but any subsequent attempts raise an error. See the reprex below:

library(hexSticker)

a <- sticker(
  subplot = ~ plot.new(),
  package = "test",
  filename = tempfile(fileext = ".png")
)

class(a)
#> [1] "sticker" "gg"      "ggplot"

a <- sticker(
  subplot = ~ plot.new(),
  package = "test",
  filename = tempfile(fileext = ".png")
)
#> Warning in editThisGrob(grob, specs): slot 'vp' not found
#> Warning in editThisGrob(grob, specs): slot 'name' not found
#> Error in UseMethod("validGrob"): no applicable method for 'validGrob' applied to an object of class "NULL"

Created on 2021-03-05 by the reprex package (v1.0.0)

aspect ratio of image subfigure not retained

It looks to me like png images etc. get stretched vertically when included? It looks to be by a factor of 600 / 518 (or 2 / 1.73, if the linked spec is to be believed). If I flatten the image in gimp or something, then include it, it seems to come out okay.

Specify sticker dimensions

Hi @GuangchuangYu. The sticker function currently has lots of arguments to tweak the size of subplot and package name. However, I couldn't find an argument to specify the sicker dimensions. How can one set the sticker dimensions to 181x209 as a png ?

ps. Thanks for the hexSticker package!

[Suggestion] Code for preview hexSticker.

Hi,
I used this hexSticker package a lot for my works, Thanks a lot. ❤️

However, while I create hexsticker, I use plot or print function to preview ( #51 ) and it's little bit different between image of Plots (of Rstudio) and real generated image like baseplot.png.
and it's repetitive job to control size or location for hexsticker.

and I found alternative approach to see preview image as created.
use imager package to load created image file and plot it to Plots (of Rstudio)


Here's example code for given examples in README.

  • This code is I used to create preview image.
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="temp.png")
print(s) # or plot(s)

which will show this image

library(hexSticker)
library(imager) 
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="temp.png")
plot(imager::load.image('temp.png'), axes = FALSE)

and this will show below image which is same for created image.


I think this approach can be applied to change in README file easily.
but I'm not sure about how to implement inside package.

Regards,

png error in creating in using sticker function

I have installed hexsticker on my machine currently using R41. I have been trying to create sticker using the example sticker and i get this error:

Error in png_dev(..., res = dpi, units = "in") :
unused arguments (type = "cairo-png", antialias = "subpixel")

I started trying it while using R40. What is the error and how can it be fixed?

I have re-installed hexsticker using the dev version and also re-installed cairo, cairodevice

Small request

I hope i would like write the word or url on the other five sides of the hexagon.
Thanks a lot.

Crop image file within shape of hexagon

Is there a way to crop a (larger) image file within the shape of the hexagon? Currently, a larger image file is put on top of the border (extending beyond the shape of the hexagon), rather than the border being the top layer, cropping the image.

E.g. @strengejacke, I was wondering how you created this logo:

ggeffects

Strip above plot

The white_around_sticker=TRUE argument doesn't cover enough area. IT leaves a small strip at the top of the plot, if there is an overflow. See the below reprex for an example:

library(hexSticker)
library(ggplot2)

#Create a plain red plot that fills the plot window
p <- ggplot() + 
  theme_void() +
  theme(plot.background=element_rect(fill="red"))

#Create the sticker
s <- sticker(p,package = "",
             s_x=1,s_y=1,s_width=2,s_height=2.5,
             white_around_sticker=TRUE)
#Plot to see it
plot(s)

Install error: error loading sysfonts

First time installing hexSticker, I get the following error and install fails:

install.packageas("hexSticker")
installing the source package ‘hexSticker’

trying URL 'https://cran.rstudio.com/src/contrib/hexSticker_0.4.2.tar.gz'
Content type 'application/x-gzip' length 676288 bytes (660 KB)
==================================================
downloaded 660 KB

* installing *source* package ‘hexSticker’ ...
** package ‘hexSticker’ successfully unpacked and MD5 sums checked
** R
** inst
** byte-compile and prepare package for lazy loading
Error : .onLoad failed in loadNamespace() for 'sysfonts', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/sysfonts/libs/sysfonts.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/sysfonts/libs/sysfonts.so, 6): Library not loaded: /opt/X11/lib/libfreetype.6.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/sysfonts/libs/sysfonts.so
  Reason: image not found
ERROR: lazy loading failed for package ‘hexSticker’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/hexSticker’
Warning in install.packages :
  installation of package ‘hexSticker’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/5_/l71sk6kn29z17n011g8kld5m0000gp/T/RtmpINzLug/downloaded_packages’

I'm using OS X 10.12.6

Greek letters in package name?

Hey, first of all, thanks for the package. :)
I have been trying to add a greek letter to the package name, but it doesn't work. This is what I have tried:

library(ggplot2)
p <- ggplot(aes(x = mpg, y = wt), data = mtcars) + geom_point()
p <- p + theme_void() + theme_transparent()
sticker(p, package = "hexSticker~lambda", parse = TRUE)
sticker(p, package = "lambda", parse = TRUE)

Any advice? :) thanks!!

add option for bold and italic fontface

The package {showtext} allows the option for bold and italic faces of font families, through the parameter fontface. An example given in the {showtext} README:

annotate("text", 1, 0.9, label = 'Chinese for "Hello, world!"',
             family = "constan", fontface = "italic", size = 12)

It would be nice to have the same functionality in {hexSticker}. Thanks!

update R version 3.5.3, and package ‘gridGraphics’ is not available

Hi, I just tried to use the package while it seemed that gridGraphics package no longer available.
And I kept got the error:
Error: package or namespace load failed for ‘hexSticker’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘gridGraphics’
Does anyone have some solution?

Border always cut off in .png or .svg

Hey, thanks for this cool package. I've made a sticker but can't seem to figure out why the left side and bottom of the border are always cut off.
I've tried on a windows and mac, R version 4.0.2. (magick version 2.6.0, hexSticker 0.4.9)
Running one of the examples:

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="lattice.png")

The result is attached

lattice

Poor Quality Sticker when Saving on Windows

In the process of creating a sticker for my {ggcharts} package I discovered that the png() device has very poor defaults on Windows. Here's what my sticker looked like when saving with sticker(). As you can see the lines are very ragged.
ggcharts_hex

I ended up doing this to get a high-quality sticker: Notice the arguments passed to type and antialias.

hex <- sticker()
png(
  filename = "sticker.png",
  width = 43.9,
  height = 50.8,
  bg = "transparent",
  units = "mm",
  type = "cairo-png",
  antialias = "subpixel",
  res = 300
)
print(hex)
dev.off()

ggcharts_hex

It would be great if hexSticker could use png() rather than ggsave() and set the type and antialias parameters as I did on Windows.

Package name to accept `expression()`

It would be great if we could pass a mathematical expression() as a package name to the sticker function.

library(ggplot2)
library(hexSticker)

p <- ggplot(aes(x = mpg, y = wt), data = mtcars) + geom_point() +
  annotate("text", x = 25, y = 5, size=8, label = expression(paste("x"^2,"y")) ) +
  theme_void() + theme_transparent()


sticker(p, package= expression(paste("x"^2,"y")), p_size=20, s_x=1, s_y=.75, s_width=1.3, s_height=1,
        filename="man/figures/ggplot2.png")


Using renamed showtext functions

Hi!

These messages are generated from version 0.5-1 of the showtext() package while running hexSticker::sticker():

'font.add()' is now renamed to 'font_add()'
The old version still works, but consider using the new function in future code
'showtext.auto()' is now renamed to 'showtext_auto()'
The old version still works, but consider using the new function in future code

Do you think it might be a good idea to use these new function names?

Thanks!

Mention imagemagick dependency in readme

It took me a few minutes to track down why my install was failing. Worked fine for me after installing imagemackick (via brew update && brew install imagemagick on OSX).

example causes R segfault

I came across this package a while ago and finally got around to taking it for a test drive. I was quite excited about making hex stickers for several of my own packages, but, unfortunately, upon trying it out today, I discovered I cannot even run the example (for working with image files) in the README relevant to my intended use case:

❯ imgurl <- "http://www.belleamibengals.com/bengal_cat_2.png"
❯ sticker(imgurl, package="hexSticker", p_size=8, s_x=1, s_y=.75, s_width=.6, filename="./imgfile.png")

 *** caught segfault ***
address 0x0, cause 'unknown'

Traceback:
 1: grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y,     resolveHJust(x$just, x$hjust), resolveVJust(x$just, x$vjust),     x$rot, x$check.overlap)
 2: drawDetails.text(x, recording = FALSE)
 3: drawDetails(x, recording = FALSE)
 4: drawGrob(x)
 5: recordGraphics(drawGrob(x), list(x = x), getNamespace("grid"))
 6: grid.draw.grob(x$children[[i]], recording = FALSE)
 7: grid.draw(x$children[[i]], recording = FALSE)
 8: drawGTree(x)
 9: recordGraphics(drawGTree(x), list(x = x), getNamespace("grid"))
10: grid.draw.gTree(x$children[[i]], recording = FALSE)
11: grid.draw(x$children[[i]], recording = FALSE)
12: drawGTree(x)
13: recordGraphics(drawGTree(x), list(x = x), getNamespace("grid"))
14: grid.draw.gTree(gtable)
15: grid.draw(gtable)
16: print.ggplot(x)
17: print(x)
18: grid.draw.ggplot(plot)
19: grid.draw(plot)
20: ggsave(sticker, width = 43.9, height = 50.8, filename = filename,     bg = "transparent", units = "mm")
21: save_sticker(filename, sticker)
22: sticker(imgurl, package = "hexSticker", p_size = 8, s_x = 1,     s_y = 0.75, s_width = 0.6, filename = "./imgfile.png")

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

I'm not exactly sure what might be going on internally, so some help in diagnosing and resolving this problem would be much appreciated.

Here's the relevant session information:

❯ sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin16.6.0 (64-bit)
Running under: macOS Sierra 10.12.5

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] hexSticker_0.4.1     forcats_0.2.0        stringr_1.2.0.9000  
 [4] dplyr_0.7.2          purrr_0.2.2.2        readr_1.1.1         
 [7] tidyr_0.6.3          tibble_1.3.3         ggplot2_2.2.1       
[10] tidyverse_1.1.1.9000 devtools_1.13.2.9000 nima_0.4.0          
[13] fcuk_0.1.21          colorout_1.1-2       prompt_1.0.0        

loaded via a namespace (and not attached):
 [1] locfit_1.5-9.1       Rcpp_0.12.12         stringdist_0.9.4.4  
 [4] lubridate_1.6.0.9009 lattice_0.20-35      sysfonts_0.6        
 [7] fftwtools_0.9-8      png_0.1-7            clisymbols_1.2.0    
[10] gtools_3.5.0         assertthat_0.2.0     digest_0.6.12       
[13] psych_1.7.5          tiff_0.1-5           R6_2.2.2            
[16] cellranger_1.1.0     plyr_1.8.4           httr_1.2.1          
[19] rlang_0.1.1.9000     lazyeval_0.2.0       readxl_1.0.0        
[22] data.table_1.10.4    rstudioapi_0.6       ProjectTemplate_0.7 
[25] hexbin_1.27.1        boxes_0.0.0.9000     foreign_0.8-69      
[28] munsell_0.4.3        broom_0.4.2          compiler_3.4.1      
[31] modelr_0.1.0         gridGraphics_0.2     pkgconfig_2.0.1     
[34] BiocGenerics_0.22.0  mnormt_1.5-5         pkgbuild_0.0.0.9000 
[37] gridExtra_2.2.1      showtextdb_1.0       crayon_1.3.2.9000   
[40] withr_1.0.2          grid_3.4.1           nlme_3.1-131
[43] jsonlite_1.5         gtable_0.2.0         DBI_0.7             
[46] magrittr_1.5         scales_0.4.1.9002    stringi_1.1.5       
[49] reshape2_1.4.2       ggthemes_3.4.0       bindrcpp_0.2        
[52] xml2_1.1.1           EBImage_4.18.0       tools_3.4.1         
[55] showtext_0.4-6       glue_1.1.1           jpeg_0.1-8          
[58] hms_0.3              abind_1.4-5          pkgload_0.0.0.9000  
[61] parallel_3.4.1       colorspace_1.3-2     rvest_0.3.2         
[64] ggimage_0.0.4        memoise_1.1.0        bindr_0.1           
[67] haven_1.1.0   

README.Rmd renders into .html instead of .md

I would like to add my sticker to the examples, so I have forked the repo and edited the README.Rmd file. However, when I run rmarkdown::render("README.Rmd"), it creates a README.html file instead of updating README.md. Is there a way to force the knitting to .md?

Feature request: display= option to show the generated sticker onscreen

sticker() should have an option, display=TRUE/FALSE where TRUE opens the created image for viewing onscreen. At present, my workaround is to use

sticker(..., filename="mysticker.png")
img <- png::readPNG("mysticker.png")
grid::grid.raster(img)

But this only works in R console, not in RStudio, because it doesn't create a plot window that can be manipulated.

sticker function fails: error in unit(rep(just$vjust), n)

Nice package, but unfortunately, I get this current fail (using your example code from the sticker fn):

library(ggplot2)
library(hexSticker)
packageVersion("hexSticker")
#> [1] '0.4.6'
p <- ggplot(aes(x = mpg, y = wt), data = mtcars) + geom_point()
p <- p + theme_void() + theme_transparent()
sticker(p, package="hexSticker")
#> Error in unit(rep(just$vjust, n), "npc") :
#> 'x' and 'units' must have length > 0

Created on 2019-10-05 by the reprex package (v0.3.0)

A fix would be much appreciated!

No border on one side of hexagon when saved as svg

Here is an example to try:

plt <- ggplot(mtcars, aes(wt, mpg)) +
  geom_smooth(size = 0.5, method = "lm") + 
  geom_point(size = 0.5) +
  theme_void()
hex_sticker <- hexSticker::sticker(plt,
                                   p_size = 7,
                                   p_y = 1.55,
                                   s_x = 1, 
                                   s_y = 0.86, 
                                   s_width = 1, 
                                   s_height = 1,
                                   package = "mtcars",
                                   h_fill = "whitesmoke",
                                   h_color = "#5c5c5c",
                                   p_color = "#377EB8")
hexSticker::save_sticker(filename = "test.svg", hex_sticker)

The output looks like this,

screenshot 2018-06-17 16 15 27

need add theme(legend.position="none") with ggplot2 plot

require(ggplot2)
library(hexSticker)
ggplot(dat, aes(x = x, y = y)) +
  geom_polygon(aes(fill = id, group = id)) +
  geom_point(aes(x = 3.25-0.5,y = 4.5),color =back_color,size = 6) +
  geom_point(aes(x = 3.25+0.5,y = 4.5),color =back_color,size = 6) +
  scale_fill_manual(values = xbox::need_colors("two5")) ->p
p <- p + theme_void() + theme_transparent() + theme(legend.position="none")

I use ggplot2 to make the back plot of hexSticker, but if i want dispaly the legend , it work only when + theme(legend.position="none") , why not add the function to theme_transparent() or new function.

I feel apologetic if the problem only occurs on me

devtools::session_info()

  • Session info -------------------------------------------------
    setting value
    version R version 4.0.2 (2020-06-22)
    os Windows 10 x64
    system x86_64, mingw32
    ui RStudio
    language (EN)
    collate Chinese (Simplified)_China.936
    ctype Chinese (Simplified)_China.936
    tz Asia/Taipei
    date 2020-12-31

  • Packages -----------------------------------------------------
    package * version date lib
    assertthat 0.2.1 2019-03-21 [1]
    backports 1.1.7 2020-05-13 [1]
    BiocGenerics 0.34.0 2020-04-27 [1]
    BiocManager 1.30.10 2019-11-16 [1]
    Biostrings 2.56.0 2020-04-27 [1]
    callr 3.4.3 2020-03-28 [1]
    cli 2.0.2 2020-02-28 [1]
    clipr 0.7.0 2019-07-23 [1]
    colorspace 2.0-0 2020-11-11 [1]
    crayon 1.3.4 2017-09-16 [1]
    datapasta 3.1.0 2020-01-17 [1]
    desc 1.2.0 2018-05-01 [1]
    devtools 2.3.1 2020-07-21 [1]
    digest 0.6.27 2020-10-24 [1]
    dplyr 1.0.1 2020-07-31 [1]
    ellipsis 0.3.1 2020-05-15 [1]
    fansi 0.4.1 2020-01-08 [1]
    farver 2.0.3 2020-01-16 [1]
    fs 1.5.0 2020-07-31 [1]
    generics 0.0.2 2018-11-29 [1]
    ggimage 0.2.8 2020-04-02 [1]
    ggplot2 * 3.3.2 2020-06-19 [1]
    ggplotify 0.0.5 2020-03-12 [1]
    glue 1.4.1 2020-05-13 [1]
    gridGraphics 0.5-1 2020-12-13 [1]
    gtable 0.3.0 2019-03-25 [1]
    hablar 0.3.0 2020-03-19 [1]
    hexbin 1.28.1 2020-02-03 [1]
    hexSticker * 0.4.9 2020-12-05 [1]
    hms 0.5.3 2020-01-08 [1]
    httr 1.4.2 2020-07-20 [1]
    IRanges 2.22.2 2020-05-21 [1]
    jsonlite 1.7.0 2020-06-25 [1]
    KEGGREST 1.28.0 2020-04-27 [1]
    labeling 0.3 2014-08-23 [1]
    lattice 0.20-41 2020-04-02 [1]
    lifecycle 0.2.0 2020-03-06 [1]
    magick 2.4.0 2020-06-23 [1]
    magrittr 1.5 2014-11-22 [1]
    memoise 1.1.0 2017-04-21 [1]
    munsell 0.5.0 2018-06-12 [1]
    pillar 1.4.6 2020-07-10 [1]
    pkgbuild 1.1.0 2020-07-13 [1]
    pkgconfig 2.0.3 2019-09-22 [1]
    pkgload 1.1.0 2020-05-29 [1]
    plyr 1.8.6 2020-03-03 [1]
    png 0.1-7 2013-12-03 [1]
    prettyunits 1.1.1 2020-01-24 [1]
    processx 3.4.3 2020-07-05 [1]
    ps 1.3.4 2020-08-11 [1]
    purrr 0.3.4 2020-04-17 [1]
    qvalue 2.20.0 2020-04-27 [1]
    R6 2.4.1 2019-11-12 [1]
    ragg 0.4.0 2020-10-05 [1]
    Rcpp 1.0.5 2020-07-06 [1]
    readr 1.3.1 2018-12-21 [1]
    remotes 2.2.0 2020-07-21 [1]
    reshape2 1.4.4 2020-04-09 [1]
    rlang 0.4.9 2020-11-26 [1]
    rprojroot 1.3-2 2018-01-03 [1]
    rstudioapi 0.11 2020-02-07 [1]
    rvcheck 0.1.8 2020-03-01 [1]
    S4Vectors 0.26.1 2020-05-16 [1]
    scales 1.1.1 2020-05-11 [1]
    sessioninfo 1.1.1 2018-11-05 [1]
    showtext 0.9 2020-08-13 [1]
    showtextdb 3.0 2020-06-04 [1]
    stringi 1.4.6 2020-02-17 [1]
    stringr 1.4.0 2019-02-10 [1]
    sysfonts 0.8.1 2020-05-08 [1]
    systemfonts 0.3.2 2020-09-29 [1]
    testthat 2.3.2 2020-03-02 [1]
    textshaping 0.2.1 2020-11-13 [1]
    tibble 3.0.3 2020-07-10 [1]
    tidyr 1.1.1 2020-07-31 [1]
    tidyselect 1.1.0 2020-05-11 [1]
    tinytex 0.25 2020-07-24 [1]
    usethis 1.6.1 2020-04-29 [1]
    vctrs 0.3.2 2020-07-15 [1]
    withr 2.2.0 2020-04-20 [1]
    xbox 0.5 2020-12-26 [1]
    xfun 0.16 2020-07-24 [1]
    XVector 0.28.0 2020-04-27 [1]
    zlibbioc 1.34.0 2020-04-27 [1]

Put package text on top layer

Would be nice if you could put the package text on the top layer of the plot to avoid it being overwritten/masked by the subplot:
test

top and bottom corners cut off

Hi,

I wanted to ask how I can prevent that the top and bottom points are being removed from the ggplot2 sticker function?
I read one of the earlier issues here, in which you suggested to install version 0.4.4, but since the current version is 0.4.9, I don't think that will resolve my issue?

The code I am using to produce the sticker:

s <- sticker(raincloud_3, package="Raincloudplots", p_size=5.5, s_x=1, s_y=.8, s_width=1.6, s_height = .8, h_fill="#F6FFFF", h_size = 2.5, h_color="darkorange", p_color = "dodgerblue",
             filename="/Users/jordyvanlangen/Desktop/rainclouds_highres.png", dpi = 900)
s

Many thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.