ggpic
extends ggplot2
package adding geoms based on the the default ones, but
using raster objects instead of rect elements. This way you can make a barplot
with trees, buildings or leaves instead bars.
# libraries
library(ggplot2)
library(ggpic)
library(dplyr)
# pic
leaf <- as.matrix(as.raster(rsvg::rsvg(
system.file('pics', 'leaf.svg', package = 'ggpic')
)))
# plot
iris %>%
ggplot(aes(x = Species, fill = Species)) +
geom_bar_pic(pic = 'leaf')
ggpic
is only at GitHub at the moment. You can install it using devtools
package:
# install devtools if necessary
install.packages('devtools')
# install ggpic
devtools::install_github('MalditoBarbudo/ggpic', build_vignettes = TRUE)
geom_bar_pic
A function to emulate geom_bar
with pics
scale_pic_manual
A scale function for pics
draw_key_pic
A guide function to be able to generate legends for the pics
"Ready to use" pics in the package, see
dir(system.file('pics', package = 'ggpic'))
. Pics also can be loaded from
a raster object.
Geoms (only geom_bar_pic is implemented at the moment) can make use of most
of the aesthetics or parameters related to their ggplot "parent" geom, i.e
fill
or width
in geom_bar_pic
.
For more examples and a complete description of the package see the Introduction to ggpic vignette:
vignette('Introducing_ggpic', package = 'ggpic')
ggpic
does not work well in a flexdashboard
environment, even if it works
in Rmd
documents. Not sure why this is happening yet.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.