clauswilke / colorblindr

An R package to simulate colorblindness on R figures.
MIT License
306 stars 29 forks source link

add vignette on adding images to plots? #1

Closed raynamharris closed 7 years ago

raynamharris commented 7 years ago

Let's say you have an image of three species of flower with an outline of each filled using the OkabeIto color scale. This way, when you view the colorblinr images you also see how colorblindness affects the accompanying visuals that use the same color scheme? Do you have a vignette for how to adding images to these plots before you export them to colorblindr?

clauswilke commented 7 years ago

Rayna, can you try again, this time in English? Also, have you looked at the vignette text Claire has written? It's not finished, but there's a lot of material already.

raynamharris commented 7 years ago

Ah. Okay, I had only looked at the README, but I found a good enough solution in the vignette using:

library(magick) p <- ggdraw() + draw_image("myimage.png") # turn png into ggplot object`. p2 <- edit_colors(p, tritan, sev = .7) p3 <- edit_colors(p, deutan, sev = .7) p4 <- edit_colors(p, protan, sev = .7) plot_grid(p, p2, p3, p4, nrow=2)

rplot

However, I know you and @clairemcwhite have ways to add images to ggplots in R rather than in Adobe (like I did to place the image in the left corner of the plot above) or some other software, but I can't seem to find any tutorials or example code where y'all have done this.

clauswilke commented 7 years ago

Look up the documentation for draw_image, part of cowplot. Easiest is to do ?draw_image on the R command line.