All Projects → gadenbuie → Ggpomological

gadenbuie / Ggpomological

Licence: other
🍑 Pomological plot theme for ggplot2

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Ggpomological

Ghibli
Studio Ghibli colour palettes
Stars: ✭ 227 (-22.53%)
Mutual labels:  ggplot2, rstats, color-palette
Econocharts
Microeconomics/macroeconomics charts in ggplot2
Stars: ✭ 161 (-45.05%)
Mutual labels:  ggplot2, rstats
Patchwork
The Composer of ggplots
Stars: ✭ 2,002 (+583.28%)
Mutual labels:  ggplot2, rstats
Ggpointdensity
📈 📊 Introduces geom_pointdensity(): A Cross Between a Scatter Plot and a 2D Density Plot.
Stars: ✭ 286 (-2.39%)
Mutual labels:  ggplot2, rstats
Soccer ggplots
Soccer/football analytics blog posts & data viz from the World Cup, Premier League, Copa America, and beyond. Using ggplot2, ggsoccer, & more. (Est. June 2018) ****Please look at the README for best version of the code!****
Stars: ✭ 115 (-60.75%)
Mutual labels:  ggplot2, rstats
Gganimate
A Grammar of Animated Graphics
Stars: ✭ 1,744 (+495.22%)
Mutual labels:  ggplot2, rstats
Plotly
An interactive graphing library for R
Stars: ✭ 2,096 (+615.36%)
Mutual labels:  ggplot2, rstats
Soccergraphr
Soccer Analytics in R using OPTA data
Stars: ✭ 42 (-85.67%)
Mutual labels:  ggplot2, rstats
gameofthrones
🎨 Game of Thrones inspired palette for R
Stars: ✭ 69 (-76.45%)
Mutual labels:  ggplot2, color-palette
cusumcharter
Easier CUSUM control charts. Returns simple CUSUM statistics, CUSUMs with control limit calculations, and function to generate faceted CUSUM Control Charts
Stars: ✭ 17 (-94.2%)
Mutual labels:  ggplot2, rstats
scclusteval
Single Cell Cluster Evaluation
Stars: ✭ 57 (-80.55%)
Mutual labels:  ggplot2, rstats
Ggbernie
A ggplot2 geom for adding Bernie Sanders to ggplot2
Stars: ✭ 96 (-67.24%)
Mutual labels:  ggplot2, rstats
Colormap
R package to generate colors from a list of 44 pre-defined palettes
Stars: ✭ 55 (-81.23%)
Mutual labels:  ggplot2, rstats
Complex Upset
A library for creating complex UpSet plots with ggplot2 geoms
Stars: ✭ 147 (-49.83%)
Mutual labels:  ggplot2, rstats
Ggeconodist
📉 Create Diminutive Distribution Charts
Stars: ✭ 53 (-81.91%)
Mutual labels:  ggplot2, rstats
Calendr
Ready to print calendars with ggplot2
Stars: ✭ 161 (-45.05%)
Mutual labels:  ggplot2, rstats
Ggcats
The geom you always wished for adding cats to ggplot2
Stars: ✭ 34 (-88.4%)
Mutual labels:  ggplot2, rstats
Ggplot Courses
👨‍🏫 ggplot2 Teaching Material
Stars: ✭ 40 (-86.35%)
Mutual labels:  ggplot2, rstats
ggchicklet
🀫 Create Chicklet (Rounded Segmented Column) Charts
Stars: ✭ 130 (-55.63%)
Mutual labels:  ggplot2, rstats
DataViz-Teaching
📈 Visualizations for DataViz Teaching
Stars: ✭ 29 (-90.1%)
Mutual labels:  ggplot2, rstats

Pomological Colors

Garrick Aden-Buie

Installation

This package isn’t on CRAN, so you’ll need to use the devtools package to install it.

# If you don't have devtools installed
install.packages("devtools")

devtools::install_github("gadenbuie/ggpomological")

# To include the vignette
devtools::install_github("gadenbuie/ggpomological", build_vignettes=TRUE)

Introduction

This package provides a ggplot2 theme inspired by the USDA Pomological Watercolors collection and by Aron Atkins’s (@aronatkins) talk on parameterized RMarkdown at rstudio::conf 2018.

[1]

Color Palette

The colors for this theme were drawn from many images from the USDA Pomological Watercolors collection, I chose just a few that I thought worked well together for color and fill scales

scales::show_col(ggpomological:::pomological_palette)

and a few colors for the plot background and decoration

scales::show_col(unlist(ggpomological:::pomological_base))

I’ve also included a css file with the complete collection of color samples.

Setup theme and scales

There are three theme-generating functions:

  • theme_pomological() sets the plot theme to be representative of the paper and styling of the watercolors and includes a paper-colored background,

  • theme_pomological_plain() has the same styling, just with a transparent (or white) background,

  • theme_pomological_fancy() has the paper-colored background and defaults to a fancy handwritten font (Homemade Apple).

For color and fill scales, ggpomological provides scale_color_pomological() and scale_fill_pomological().

In the future, I might revisit this package to

  1. Increase colors in discrete scale

  2. Setup paired color scales. Lots of great color pairs in the extracted colors.

  3. Set up continuous scale colors (we’ll see…)

Fonts

A handwriting font is needed for the fully authentic pomological look, and I found a few from Google Fonts that fit the bill.

Alternatively, use something like calligrapher.com to create your own handwriting font!

But fonts can be painful in R, so the base functions – theme_pomological() and theme_pomological_plain() – don’t change the font by default. To opt into the full pomological effect, use theme_pomological_fancy() which is just an alias for theme_pomological(base_family = "Homemade Apple", base_size = 16).

Add paper background!

ggpomological also provides a function named paint_pomological that uses the magick package to add a pomological watercolor paper background and a subtle texture overlay.

Demo!

We’ll need ggplot2 (loaded with ggpomological) and dplyr

library(ggpomological)
library(dplyr)

Warning: If you don’t have the above fonts installed, you’ll get an error message with a lot of warnings when running the below examples. Just replace theme_pomological("Homemade Apple", 16) with theme_pomological() for the basic theme without the crazy fonts.

Basic iris plot

# Prep msleep data
msleep <- ggplot2::msleep[, c("vore", "sleep_rem", "sleep_total")]
msleep <- msleep[complete.cases(msleep), ]
msleep$vore <- paste0(msleep$vore, "vore")

# Base plot
basic_msleep_plot <- ggplot(msleep) +
  aes(x = sleep_rem, y = sleep_total, color = vore) +
  geom_point(size = 2) +
  labs(color = NULL)

# Just your standard ggplot
basic_msleep_plot 


# With pomological colors
basic_msleep_plot <- basic_msleep_plot + scale_color_pomological()
basic_msleep_plot


# With pomological theme
basic_msleep_plot + theme_pomological()


# With transparent background
basic_msleep_plot + theme_pomological_plain() 


# Or with "fancy" pomological settings
pomological_msleep <- basic_msleep_plot + theme_pomological_fancy()

# Painted!
paint_pomological(pomological_msleep, res = 110)

Stacked bar chart

stacked_bar_plot <- ggplot(diamonds) +
  aes(price, fill = cut) +
  geom_histogram(binwidth = 850) + 
  xlab('Price (USD)') + 
  ylab('Count') + 
  ggtitle("ggpomological") +
  scale_x_continuous(labels = scales::dollar_format()) +
  scale_fill_pomological()

stacked_bar_plot + theme_pomological("Homemade Apple", 16)


paint_pomological(
  stacked_bar_plot + theme_pomological_fancy("Homemade Apple"),
  res = 110
)

Density Plot

density_plot <- mtcars %>% 
  mutate(cyl = factor(cyl)) %>% 
  ggplot() +
  aes(mpg, fill = cyl, color = cyl)+
  geom_density(alpha = 0.75) + 
  labs(fill = 'Cylinders', colour = 'Cylinders', x = 'MPG', y = 'Density') +
  scale_color_pomological() +
  scale_fill_pomological()

density_plot + theme_pomological("Homemade Apple", 16)


paint_pomological(
  density_plot + theme_pomological_fancy(),
  res = 110
)

Points and lines

Data from the Texas Housing

big_volume_cities <- txhousing %>% 
  group_by(city) %>% 
  summarize(mean_volume = mean(volume, na.rm = TRUE)) %>% 
  arrange(-mean_volume) %>% 
  top_n(length(ggpomological:::pomological_palette)) %>% 
  pull(city)
#> Selecting by mean_volume

full_bar_stack_plot <- txhousing %>% 
  filter(city %in% big_volume_cities) %>% 
  group_by(city, year) %>% 
  summarize(mean_volume = mean(volume, na.rm = TRUE)) %>% 
  ungroup %>% 
  mutate(city = factor(city, big_volume_cities)) %>% 
  ggplot() +
  aes(year, mean_volume, fill = city, group = city) +
  geom_col(position = 'fill', width = 0.9) +
  labs(x = 'City', y = 'Mean Volume', color = 'City') +
  theme(panel.grid.minor.x = element_blank()) +
  scale_fill_pomological()

full_bar_stack_plot + theme_pomological("Homemade Apple", 16)


paint_pomological(
  full_bar_stack_plot + theme_pomological_fancy(),
  res = 110
)

One last plot

Using my own handwriting and the ggridges package.

ridges_pomological <- ggplot(diamonds) + 
  aes(x = carat, y = clarity, color = clarity, fill = clarity) + 
  ggridges::geom_density_ridges(alpha = 0.75) + 
  theme_pomological(
    base_family = 'gWriting',
    base_size = 20,
    base_theme = ggridges::theme_ridges()
    ) + 
  scale_fill_pomological() + 
  scale_color_pomological()

paint_pomological(ridges_pomological, res = 110)
#> Picking joint bandwidth of 0.057

  1. U.S. Department of Agriculture Pomological Watercolor Collection. Rare and Special Collections, National Agricultural Library, Beltsville, MD 20705
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].