Saturday 16 February 2019

r - how to achieve a hand-drawn pencil fill in ggplot2?

I came across this great blog post on visualizations: http://www.darkhorseanalytics.com/blog/visualizing-distributions-3
It includes a set of plots with an aesthetic that looks like hand-drawn pencil. Is there a way to get a textured fill like this in R, preferably using ggplot2? I know about the hand-drawn fonts and lines available in the xkcd package, but I'm particularly interested in getting the hand-drawn fill effect, as shown in the following histogram (taken from the darkhorseanalytics link posted above), which isn't available in the xkcd package.



darkhorseanalytics pencil-fill histogram



Any ideas on how to create something like that in R?




To be clear, I'm looking for ideas about how to generate a hand-drawn fill effect, similar to the hand-drawn effect for lines that has been the subject of very productive brainstorming on this site. Fill effects are not easy to implement in ggplot2, but not impossible. Jittering a diagonal fill lines effect may be a reasonable place to start. Ben also mentioned annotation_raster() which would be another reasonable approach.



I know fill textures are not currently a priority for the ggplot2 development team, and they're difficult to implement for a number of reasons. That doesn't mean that they wouldn't be useful to have, or that we can't try to figure something out. :)

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...