knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "75%", dpi = 300 )
A collection of cute things to use with ggplot2.
You can install ggcute from GitHub with:
# install.packages("remotes") remotes::install_github("sharlagelfand/ggcute")
theme_fairyfloss()
is a theme based off of sailorhg's fairyfloss text editor theme.
You can use it like any other ggplot2 theme:
library(ggplot2) library(ggcute) ggplot(nintendo_sales, aes(x = sales_million, y = console)) + geom_col() + facet_wrap(~sales_type) + theme_fairyfloss()
It's probably (definitely) not a complete theme but at least it's cute r emo::ji("cloud")
There is a colour palette built in:
library(scales) show_col(ggcute:::fairyfloss_colours)
You can use it in plots via scale_fill_fairyfloss()
:
ggplot(nintendo_sales, aes(x = sales_million, y = console, fill = sales_type)) + geom_col(position = position_dodge2(width = 0.1), alpha = 0.75) + labs( x = "Sales (million)", y = "Console", title = "Nintendo sales by console", subtitle = "As of December 31, 2019" ) + scale_fill_fairyfloss() + theme_fairyfloss()
or scale_colour_fairyfloss()
("color" instead of colour works too):
ggplot(nintendo_sales, aes(x = sales_type, y = sales_million, colour = console)) + geom_jitter(size = 5, alpha = 0.5) + scale_colour_fairyfloss() + theme_fairyfloss(base_size = 12) + theme( legend.position = "bottom", legend.title = element_blank() )
Of course, you can use the palette without the theme and it's still extremely cute:
ggplot(head(diamonds, 1000), aes(x = cut, y = carat, colour = carat)) + geom_jitter() + scale_colour_fairyfloss(discrete = FALSE) + theme_minimal()
theme_sugarpill()
is a theme based off the Sugarpill Fun Size eyeshadow palette. Similar to fairyfloss, there are also scale_*_sugarpill()
functions.
library(dplyr) library(forcats) nintendo_sales %>% mutate(console = fct_lump_n(console, n = 8, w = sales_million, other_level = "Other Consoles")) %>% group_by(console, sales_type) %>% summarise(sales_million = sum(sales_million)) %>% ungroup() %>% ggplot(aes(x = sales_type, y = sales_million, fill = console)) + geom_col(position = position_dodge2()) + facet_wrap(vars(console)) + labs( x = "", y = "", title = "Nintendo units sold (millions) by console", subtitle = "Data as of December 31, 2019" ) + scale_fill_sugarpill() + theme_sugarpill() + theme(legend.position = "none")
ggcute
comes with one data set built in, Nintendo sales as of December 31, 2019:
nintendo_sales
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.