| Package: ggpomological | Package: ggpomological | ||||
| Version: 0.1.0 | |||||
| Version: 0.1.1 | |||||
| Title: Pomological plot themes for ggplot2 | Title: Pomological plot themes for ggplot2 | ||||
| Description: Pomological plot themes and scales for ggplot2 (in progress) | Description: Pomological plot themes and scales for ggplot2 (in progress) | ||||
| Authors@R: person("Garrick", "Aden-Buie", , "g.adenbuie@gmail.com", c("aut", "cre")) | Authors@R: person("Garrick", "Aden-Buie", , "g.adenbuie@gmail.com", c("aut", "cre")) |
| export(scale_colour_pomological) | export(scale_colour_pomological) | ||||
| export(scale_fill_pomological) | export(scale_fill_pomological) | ||||
| export(theme_pomological) | export(theme_pomological) | ||||
| export(theme_pomological_fancy) | |||||
| export(theme_pomological_nobg) | export(theme_pomological_nobg) | ||||
| export(theme_pomological_plain) | export(theme_pomological_plain) |
| # ggpomological 0.1.1 | |||||
| * Do not mess with fonts as default values of `theme_pomological()`. Created `theme_pomological_fancy()` as wrapper with fancy font defaults instead. |
| #' basic_iris_plot + | #' basic_iris_plot + | ||||
| #' theme_pomological() | #' theme_pomological() | ||||
| #' | #' | ||||
| #' # Don't change panel grid color | |||||
| #' # With fonts (manual) | |||||
| #' basic_iris_plot + | #' basic_iris_plot + | ||||
| #' theme_pomological( | |||||
| #' panel.grid.color = NULL | |||||
| #' ) | |||||
| #' theme_pomological("Homemade Apple", 16) | |||||
| #' | #' | ||||
| #' # White background | |||||
| #' # Or with fancy alias (same as previous) | |||||
| #' basic_iris_plot + | #' basic_iris_plot + | ||||
| #' theme_pomological_nobg() | |||||
| #' theme_pomological_fancy() | |||||
| #' | #' | ||||
| #' # Plain plot without font or background | #' # Plain plot without font or background | ||||
| #' basic_iris_plot + | #' basic_iris_plot + | ||||
| #' | #' | ||||
| #' @export | #' @export | ||||
| theme_pomological <- function( | theme_pomological <- function( | ||||
| base_family = "Homemade Apple", | |||||
| base_size = 14, | |||||
| base_family = NULL, | |||||
| base_size = 11, | |||||
| text.color = pomological_base$dark_blue, | text.color = pomological_base$dark_blue, | ||||
| plot.background.color = pomological_base$paper, | plot.background.color = pomological_base$paper, | ||||
| panel.border.color = pomological_base$light_line, | panel.border.color = pomological_base$light_line, | ||||
| base_theme + | base_theme + | ||||
| ggplot2::theme( | ggplot2::theme( | ||||
| text = ggplot2::element_text( | text = ggplot2::element_text( | ||||
| family = base_family, | |||||
| family = if (!is.null(base_family)) base_family, | |||||
| size = base_size, | size = base_size, | ||||
| colour = text.color | colour = text.color | ||||
| ), | ), | ||||
| #' @describeIn theme_pomological Pomological theme with white (transparent) background | #' @describeIn theme_pomological Pomological theme with white (transparent) background | ||||
| #' @export | #' @export | ||||
| theme_pomological_nobg <- function(...) { | |||||
| dots <- list(...) | |||||
| dots$plot.background.color <- "transparent" | |||||
| do.call("theme_pomological", args = dots) | |||||
| theme_pomological_nobg <- function(..., plot.background.color = "transparent") { | |||||
| theme_pomological(plot.background.color = plot.background.color, ...) | |||||
| } | } | ||||
| #' @describeIn theme_pomological A "plain" pomological theme with white | #' @describeIn theme_pomological A "plain" pomological theme with white | ||||
| #' background and normal fonts. | |||||
| #' background and normal fonts. | |||||
| #' @export | #' @export | ||||
| theme_pomological_plain <- function(...) { | |||||
| dots <- list(...) | |||||
| dots$plot.background.color <- "transparent" | |||||
| if (!"base_family" %in% names(dots)) dots["base_family"] <- "" | |||||
| if (!"base_size" %in% names(dots)) dots["base_size"] <- 11 | |||||
| do.call("theme_pomological", args = dots) | |||||
| theme_pomological_plain <- function(base_family = "", base_size = 11, plot.background.color = "transparent", ...) { | |||||
| theme_pomological(base_family, base_size, plot.background.color = plot.background.color, ...) | |||||
| } | |||||
| #' @describeIn theme_pomological A "fancy" pomological theme with fancy fonts | |||||
| #' @export | |||||
| theme_pomological_fancy <- function(base_family = "Homemade Apple", base_size = 16, ...) { | |||||
| theme_pomological(base_family, base_size, ...) | |||||
| } | } | ||||
| font_urls <- data.frame( | font_urls <- data.frame( |
| --- | --- | ||||
| title: "Pomological Colors" | title: "Pomological Colors" | ||||
| author: "Garrick Aden-Buie" | author: "Garrick Aden-Buie" | ||||
| date: "2/4/2018" | |||||
| output: github_document | output: github_document | ||||
| editor_options: | editor_options: | ||||
| chunk_output_type: console | chunk_output_type: console | ||||
| library(dplyr) | library(dplyr) | ||||
| ``` | ``` | ||||
| ## Pomological Plots | |||||
| <!-- Links --> | <!-- Links --> | ||||
| [rstudioconf]: https://www.rstudio.com/conference/ | [rstudioconf]: https://www.rstudio.com/conference/ | ||||
| labs(x = "Space", y = "Time", | labs(x = "Space", y = "Time", | ||||
| color = "Fruit", title = "ggpomological") + | color = "Fruit", title = "ggpomological") + | ||||
| scale_color_pomological() + | scale_color_pomological() + | ||||
| theme_pomological() | |||||
| theme_pomological_fancy() | |||||
| } %>% | } %>% | ||||
| paint_pomological(res = 110) %>% | paint_pomological(res = 110) %>% | ||||
| magick::image_write("Readme_files/figure-gfm/ggpomological.png") | magick::image_write("Readme_files/figure-gfm/ggpomological.png") | ||||
|  |  | ||||
|  | |||||
| ^[U.S. Department of Agriculture Pomological Watercolor Collection. Rare and Special Collections, National Agricultural Library, Beltsville, MD 20705] | |||||
| ## Installation | ## Installation | ||||
| - `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()` sets the plot theme to be representative of the paper and styling of the watercolors and includes a paper-colored background, | ||||
| - `theme_pomological_nobg()` has the same styling, just with a transparent (or white) background, | |||||
| - `theme_pomological_plain()` has the same styling, just with a transparent (or white) background, | |||||
| - `theme_pomological_plain()` has a white background and doesn't change the font unless requested. | |||||
| - `theme_pomological_fancy()` has the paper-colored background and defaults to a fancy handwritten font ([Homemade Apple](https://fonts.google.com/specimen/Homemade+Apple/)). | |||||
| A handwriting font is needed for the fully authentic pomological look, and I found a few from Google Fonts that fit the bill. | |||||
| - [Mr. De Haviland](https://fonts.google.com/specimen/Mr+De+Haviland) | |||||
| - [Homemade Apple](https://fonts.google.com/specimen/Homemade+Apple/) | |||||
| - [Marck Script](https://fonts.google.com/specimen/Marck+Script/) | |||||
| - [Mr. Bedfort](https://fonts.google.com/specimen/Mr+Bedfort/) | |||||
| Alternatively, use something like [calligrapher.com](https://www.calligraphr.com/) to create your own handwriting font! | |||||
| For color and fill scales, **ggpomological** provides `scale_color_pomological()` and `scale_fill_pomological()`. | For color and fill scales, **ggpomological** provides `scale_color_pomological()` and `scale_fill_pomological()`. | ||||
| 3. Set up continuous scale colors (we'll see...) | 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. | |||||
| - [Mr. De Haviland](https://fonts.google.com/specimen/Mr+De+Haviland) | |||||
| - [Homemade Apple](https://fonts.google.com/specimen/Homemade+Apple/) | |||||
| - [Marck Script](https://fonts.google.com/specimen/Marck+Script/) | |||||
| - [Mr. Bedfort](https://fonts.google.com/specimen/Mr+Bedfort/) | |||||
| Alternatively, use something like [calligrapher.com](https://www.calligraphr.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! | ## Add paper background! | ||||
| library(dplyr) | library(dplyr) | ||||
| ``` | ``` | ||||
| **Warning**: If you don't have the [above fonts](#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 | ### Basic iris plot | ||||
| ```{r plot-demo} | ```{r plot-demo} | ||||
| basic_iris_plot | basic_iris_plot | ||||
| # With pomological theme | # With pomological theme | ||||
| pomological_iris <- basic_iris_plot + theme_pomological() | |||||
| pomological_iris | |||||
| basic_iris_plot + theme_pomological() | |||||
| # With transparent background | # With transparent background | ||||
| basic_iris_plot + theme_pomological_nobg() | |||||
| # Or with "plain" pomological | |||||
| basic_iris_plot + theme_pomological_plain() | basic_iris_plot + theme_pomological_plain() | ||||
| # Or with "fancy" pomological settings | |||||
| pomological_iris <- basic_iris_plot + theme_pomological_fancy() | |||||
| # Painted! | # Painted! | ||||
| paint_pomological(pomological_iris, res = 110) %>% | paint_pomological(pomological_iris, res = 110) %>% | ||||
| magick::image_write("Readme_files/figure-gfm/plot-demo-painted.png") | magick::image_write("Readme_files/figure-gfm/plot-demo-painted.png") | ||||
| scale_x_continuous(label = scales::dollar_format()) + | scale_x_continuous(label = scales::dollar_format()) + | ||||
| scale_fill_pomological() | scale_fill_pomological() | ||||
| stacked_bar_plot + theme_pomological() | |||||
| stacked_bar_plot + theme_pomological("Homemade Apple", 16) | |||||
| paint_pomological( | paint_pomological( | ||||
| stacked_bar_plot + theme_pomological_nobg(), | |||||
| stacked_bar_plot + theme_pomological_fancy(), | |||||
| res = 110 | res = 110 | ||||
| ) %>% | ) %>% | ||||
| magick::image_write("Readme_files/figure-gfm/plot-bar-chart-painted.png") | magick::image_write("Readme_files/figure-gfm/plot-bar-chart-painted.png") | ||||
| scale_color_pomological() + | scale_color_pomological() + | ||||
| scale_fill_pomological() | scale_fill_pomological() | ||||
| density_plot + theme_pomological() | |||||
| density_plot + theme_pomological("Homemade Apple", 16) | |||||
| paint_pomological( | paint_pomological( | ||||
| density_plot + theme_pomological_nobg(), | |||||
| density_plot + theme_pomological_fancy(), | |||||
| res = 110 | res = 110 | ||||
| ) %>% | ) %>% | ||||
| magick::image_write("Readme_files/figure-gfm/plot-density-demo-painted.png") | magick::image_write("Readme_files/figure-gfm/plot-density-demo-painted.png") | ||||
| theme(panel.grid.minor.x = element_blank()) + | theme(panel.grid.minor.x = element_blank()) + | ||||
| scale_fill_pomological() | scale_fill_pomological() | ||||
| full_bar_stack_plot + theme_pomological() | |||||
| full_bar_stack_plot + theme_pomological("Homemade Apple", 16) | |||||
| paint_pomological( | paint_pomological( | ||||
| full_bar_stack_plot + theme_pomological_nobg(), | |||||
| full_bar_stack_plot + theme_pomological_fancy(), | |||||
| res = 110 | res = 110 | ||||
| ) %>% | ) %>% | ||||
| magick::image_write("Readme_files/figure-gfm/plot-full-bar-stack-painted.png") | magick::image_write("Readme_files/figure-gfm/plot-full-bar-stack-painted.png") | ||||
| ridges_pomological <- ggplot(diamonds) + | ridges_pomological <- ggplot(diamonds) + | ||||
| aes(x = carat, y = clarity, color = clarity, fill = clarity) + | aes(x = carat, y = clarity, color = clarity, fill = clarity) + | ||||
| ggridges::geom_density_ridges(alpha = 0.75) + | ggridges::geom_density_ridges(alpha = 0.75) + | ||||
| theme_pomological_nobg( | |||||
| theme_pomological( | |||||
| base_family = 'gWriting', | base_family = 'gWriting', | ||||
| base_size = 20, | base_size = 20, | ||||
| base_theme = ggridges::theme_ridges() | base_theme = ggridges::theme_ridges() |
| Pomological Colors | Pomological Colors | ||||
| ================ | ================ | ||||
| Garrick Aden-Buie | Garrick Aden-Buie | ||||
| 2/4/2018 | |||||
| ## Pomological Plots | |||||
| <!-- Links --> | <!-- Links --> | ||||
|  |  | ||||
|  | |||||
| \[1\] | |||||
| ## Installation | ## Installation | ||||
| the paper and styling of the watercolors and includes a | the paper and styling of the watercolors and includes a | ||||
| paper-colored background, | paper-colored background, | ||||
| - `theme_pomological_nobg()` has the same styling, just with a | |||||
| - `theme_pomological_plain()` has the same styling, just with a | |||||
| transparent (or white) background, | transparent (or white) background, | ||||
| - `theme_pomological_plain()` has a white background and doesn’t | |||||
| change the font unless requested. | |||||
| - `theme_pomological_fancy()` has the paper-colored background and | |||||
| defaults to a fancy handwritten font ([Homemade | |||||
| Apple](https://fonts.google.com/specimen/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, | A handwriting font is needed for the fully authentic pomological look, | ||||
| and I found a few from Google Fonts that fit the bill. | and I found a few from Google Fonts that fit the bill. | ||||
| [calligrapher.com](https://www.calligraphr.com/) to create your own | [calligrapher.com](https://www.calligraphr.com/) to create your own | ||||
| handwriting font\! | handwriting font\! | ||||
| 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…) | |||||
| 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\! | ## Add paper background\! | ||||
| library(dplyr) | library(dplyr) | ||||
| ``` | ``` | ||||
| **Warning**: If you don’t have the [above fonts](#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 | ### Basic iris plot | ||||
| ``` r | ``` r | ||||
| ``` r | ``` r | ||||
| # With pomological theme | # With pomological theme | ||||
| pomological_iris <- basic_iris_plot + theme_pomological() | |||||
| pomological_iris | |||||
| basic_iris_plot + theme_pomological() | |||||
| ``` | ``` | ||||
| <!-- --> | <!-- --> | ||||
| ``` r | ``` r | ||||
| # With transparent background | # With transparent background | ||||
| basic_iris_plot + theme_pomological_nobg() | |||||
| basic_iris_plot + theme_pomological_plain() | |||||
| ``` | ``` | ||||
| <!-- --> | <!-- --> | ||||
| ``` r | ``` r | ||||
| # Or with "plain" pomological | |||||
| basic_iris_plot + theme_pomological_plain() | |||||
| ``` | |||||
| <!-- --> | |||||
| # Or with "fancy" pomological settings | |||||
| pomological_iris <- basic_iris_plot + theme_pomological_fancy() | |||||
| ``` r | |||||
| # Painted! | # Painted! | ||||
| paint_pomological(pomological_iris, res = 110) %>% | paint_pomological(pomological_iris, res = 110) %>% | ||||
| magick::image_write("Readme_files/figure-gfm/plot-demo-painted.png") | magick::image_write("Readme_files/figure-gfm/plot-demo-painted.png") | ||||
| scale_x_continuous(label = scales::dollar_format()) + | scale_x_continuous(label = scales::dollar_format()) + | ||||
| scale_fill_pomological() | scale_fill_pomological() | ||||
| stacked_bar_plot + theme_pomological() | |||||
| stacked_bar_plot + theme_pomological("Homemade Apple", 16) | |||||
| ``` | ``` | ||||
| <!-- --> | <!-- --> | ||||
| ``` r | ``` r | ||||
| paint_pomological( | paint_pomological( | ||||
| stacked_bar_plot + theme_pomological_nobg(), | |||||
| stacked_bar_plot + theme_pomological_fancy(), | |||||
| res = 110 | res = 110 | ||||
| ) %>% | ) %>% | ||||
| magick::image_write("Readme_files/figure-gfm/plot-bar-chart-painted.png") | magick::image_write("Readme_files/figure-gfm/plot-bar-chart-painted.png") | ||||
| scale_color_pomological() + | scale_color_pomological() + | ||||
| scale_fill_pomological() | scale_fill_pomological() | ||||
| density_plot + theme_pomological() | |||||
| density_plot + theme_pomological("Homemade Apple", 16) | |||||
| ``` | ``` | ||||
| <!-- --> | <!-- --> | ||||
| ``` r | ``` r | ||||
| paint_pomological( | paint_pomological( | ||||
| density_plot + theme_pomological_nobg(), | |||||
| density_plot + theme_pomological_fancy(), | |||||
| res = 110 | res = 110 | ||||
| ) %>% | ) %>% | ||||
| magick::image_write("Readme_files/figure-gfm/plot-density-demo-painted.png") | magick::image_write("Readme_files/figure-gfm/plot-density-demo-painted.png") | ||||
| theme(panel.grid.minor.x = element_blank()) + | theme(panel.grid.minor.x = element_blank()) + | ||||
| scale_fill_pomological() | scale_fill_pomological() | ||||
| full_bar_stack_plot + theme_pomological() | |||||
| full_bar_stack_plot + theme_pomological("Homemade Apple", 16) | |||||
| ``` | ``` | ||||
| <!-- --> | <!-- --> | ||||
| ``` r | ``` r | ||||
| paint_pomological( | paint_pomological( | ||||
| full_bar_stack_plot + theme_pomological_nobg(), | |||||
| full_bar_stack_plot + theme_pomological_fancy(), | |||||
| res = 110 | res = 110 | ||||
| ) %>% | ) %>% | ||||
| magick::image_write("Readme_files/figure-gfm/plot-full-bar-stack-painted.png") | magick::image_write("Readme_files/figure-gfm/plot-full-bar-stack-painted.png") | ||||
| ridges_pomological <- ggplot(diamonds) + | ridges_pomological <- ggplot(diamonds) + | ||||
| aes(x = carat, y = clarity, color = clarity, fill = clarity) + | aes(x = carat, y = clarity, color = clarity, fill = clarity) + | ||||
| ggridges::geom_density_ridges(alpha = 0.75) + | ggridges::geom_density_ridges(alpha = 0.75) + | ||||
| theme_pomological_nobg( | |||||
| theme_pomological( | |||||
| base_family = 'gWriting', | base_family = 'gWriting', | ||||
| base_size = 20, | base_size = 20, | ||||
| base_theme = ggridges::theme_ridges() | base_theme = ggridges::theme_ridges() | ||||
| ## Picking joint bandwidth of 0.057 | ## 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 |
| \alias{theme_pomological} | \alias{theme_pomological} | ||||
| \alias{theme_pomological_nobg} | \alias{theme_pomological_nobg} | ||||
| \alias{theme_pomological_plain} | \alias{theme_pomological_plain} | ||||
| \alias{theme_pomological_fancy} | |||||
| \title{Pomological Theme} | \title{Pomological Theme} | ||||
| \usage{ | \usage{ | ||||
| theme_pomological(base_family = "Homemade Apple", base_size = 18, | |||||
| theme_pomological(base_family = NULL, base_size = 11, | |||||
| text.color = pomological_base$dark_blue, | text.color = pomological_base$dark_blue, | ||||
| plot.background.color = pomological_base$paper, | plot.background.color = pomological_base$paper, | ||||
| panel.border.color = pomological_base$light_line, with.panel.grid = FALSE, | panel.border.color = pomological_base$light_line, with.panel.grid = FALSE, | ||||
| axis.text.color = pomological_base$medium_line, axis.text.size = base_size | axis.text.color = pomological_base$medium_line, axis.text.size = base_size | ||||
| * 3/4, base_theme = ggplot2::theme_minimal()) | * 3/4, base_theme = ggplot2::theme_minimal()) | ||||
| theme_pomological_nobg(...) | |||||
| theme_pomological_nobg(..., plot.background.color = "transparent") | |||||
| theme_pomological_plain(...) | |||||
| theme_pomological_plain(base_family = "", base_size = 11, | |||||
| plot.background.color = "transparent", ...) | |||||
| theme_pomological_fancy(base_family = "Homemade Apple", base_size = 16, ...) | |||||
| } | } | ||||
| \arguments{ | \arguments{ | ||||
| \item{base_family}{Base text family. See \strong{Fonts} in \code{\link[=theme_pomological]{theme_pomological()}} | \item{base_family}{Base text family. See \strong{Fonts} in \code{\link[=theme_pomological]{theme_pomological()}} | ||||
| \item \code{theme_pomological_plain}: A "plain" pomological theme with white | \item \code{theme_pomological_plain}: A "plain" pomological theme with white | ||||
| background and normal fonts. | background and normal fonts. | ||||
| \item \code{theme_pomological_fancy}: A "fancy" pomological theme with fancy fonts | |||||
| }} | }} | ||||
| \section{Fonts}{ | \section{Fonts}{ | ||||
| basic_iris_plot + | basic_iris_plot + | ||||
| theme_pomological() | theme_pomological() | ||||
| # Don't change panel grid color | |||||
| # With fonts (manual) | |||||
| basic_iris_plot + | basic_iris_plot + | ||||
| theme_pomological( | |||||
| panel.grid.color = NULL | |||||
| ) | |||||
| theme_pomological("Homemade Apple", 16) | |||||
| # White background | |||||
| # Or with fancy alias (same as previous) | |||||
| basic_iris_plot + | basic_iris_plot + | ||||
| theme_pomological_nobg() | |||||
| theme_pomological_fancy() | |||||
| # Plain plot without font or background | # Plain plot without font or background | ||||
| basic_iris_plot + | basic_iris_plot + |