| ByteCompile: true | ByteCompile: true | ||||
| URL: https://github.com/gadenbuie/ggpomological | URL: https://github.com/gadenbuie/ggpomological | ||||
| BugReports: https://github.com/gadenbuie/ggpomological/issues | BugReports: https://github.com/gadenbuie/ggpomological/issues | ||||
| RoxygenNote: 6.0.1 | |||||
| RoxygenNote: 7.1.0 | |||||
| Roxygen: list(markdown = TRUE) | Roxygen: list(markdown = TRUE) | ||||
| Depends: | Depends: | ||||
| ggplot2 | ggplot2 |
| #' | #' | ||||
| #' @examples | #' @examples | ||||
| #' library(ggplot2) | #' library(ggplot2) | ||||
| #' basic_iris_plot <- ggplot(iris) + | |||||
| #' aes(x = Sepal.Length, y = Sepal.Width, color = Species) + | |||||
| #' | |||||
| #' # 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) + | #' geom_point(size = 2) + | ||||
| #' # with pomological color scale | |||||
| #' scale_color_pomological() | |||||
| #' 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() | |||||
| #' | #' | ||||
| #' # Pomological Theme | |||||
| #' basic_iris_plot + | |||||
| #' theme_pomological() | |||||
| #' # Or with "fancy" pomological settings | |||||
| #' pomological_msleep <- basic_msleep_plot + theme_pomological_fancy() | |||||
| #' | #' | ||||
| #' # With fonts (manual) | |||||
| #' basic_iris_plot + | |||||
| #' theme_pomological("Homemade Apple", 16) | |||||
| #' | |||||
| #' # Or with fancy alias (same as previous) | |||||
| #' basic_iris_plot + | |||||
| #' theme_pomological_fancy() | |||||
| #' | |||||
| #' # Plain plot without font or background | |||||
| #' basic_iris_plot + | |||||
| #' theme_pomological_plain() | |||||
| #' # Painted! | |||||
| #' paint_pomological(pomological_msleep, res = 110) | |||||
| #' | #' | ||||
| #' @export | #' @export | ||||
| theme_pomological <- function( | theme_pomological <- function( |
| ## Introduction | ## Introduction | ||||
| ```{r readme, child = "vignettes/ggpomological.Rmd", out.dir="Readme_files/figure-gfm/"} | |||||
| ```{r include=FALSE} | |||||
| README <- TRUE | |||||
| knitr::opts_chunk$set(fig.path = "man/figures/") | |||||
| ``` | |||||
| ```{r readme, child = "vignettes/ggpomological.Rmd", out.dir=here::here("man", "figures")} | |||||
| ``` | ``` |
| parameterized RMarkdown](https://youtu.be/Ol1FjFR2IMU?t=5h21m15s) at | parameterized RMarkdown](https://youtu.be/Ol1FjFR2IMU?t=5h21m15s) at | ||||
| [rstudio::conf 2018](https://www.rstudio.com/conference/). | [rstudio::conf 2018](https://www.rstudio.com/conference/). | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| <!-- -->[^1] | |||||
| <!-- -->\[1\] | |||||
| ## Color Palette | ## Color Palette | ||||
| scales::show_col(ggpomological:::pomological_palette) | scales::show_col(ggpomological:::pomological_palette) | ||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| and a few colors for the plot background and decoration | and a few colors for the plot background and decoration | ||||
| scales::show_col(unlist(ggpomological:::pomological_base)) | scales::show_col(unlist(ggpomological:::pomological_base)) | ||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| I’ve also included a [css file](inst/pomological.css) with the complete | I’ve also included a [css file](inst/pomological.css) with the complete | ||||
| collection of color samples. | collection of color samples. | ||||
| ### Basic iris plot | ### Basic iris plot | ||||
| ``` r | ``` r | ||||
| # 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 | # Base plot | ||||
| basic_iris_plot <- ggplot(iris) + | |||||
| aes(x = Sepal.Length, y = Sepal.Width, color = Species) + | |||||
| geom_point(size = 2) | |||||
| basic_msleep_plot <- ggplot(msleep) + | |||||
| aes(x = sleep_rem, y = sleep_total, color = vore) + | |||||
| geom_point(size = 2) + | |||||
| labs(color = NULL) | |||||
| # Just your standard Iris plot | |||||
| basic_iris_plot | |||||
| # Just your standard ggplot | |||||
| basic_msleep_plot | |||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ``` r | ``` r | ||||
| # With pomological colors | # With pomological colors | ||||
| basic_iris_plot <- basic_iris_plot + scale_color_pomological() | |||||
| basic_iris_plot | |||||
| basic_msleep_plot <- basic_msleep_plot + scale_color_pomological() | |||||
| basic_msleep_plot | |||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ``` r | ``` r | ||||
| # With pomological theme | # With pomological theme | ||||
| basic_iris_plot + theme_pomological() | |||||
| basic_msleep_plot + theme_pomological() | |||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ``` r | ``` r | ||||
| # With transparent background | # With transparent background | ||||
| basic_iris_plot + theme_pomological_plain() | |||||
| basic_msleep_plot + theme_pomological_plain() | |||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ``` r | ``` r | ||||
| # Or with "fancy" pomological settings | # Or with "fancy" pomological settings | ||||
| pomological_iris <- basic_iris_plot + theme_pomological_fancy() | |||||
| pomological_msleep <- basic_msleep_plot + theme_pomological_fancy() | |||||
| # Painted! | # Painted! | ||||
| paint_pomological(pomological_iris, res = 110) | |||||
| paint_pomological(pomological_msleep, res = 110) | |||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ### Stacked bar chart | ### Stacked bar chart | ||||
| xlab('Price (USD)') + | xlab('Price (USD)') + | ||||
| ylab('Count') + | ylab('Count') + | ||||
| ggtitle("ggpomological") + | ggtitle("ggpomological") + | ||||
| scale_x_continuous(label = scales::dollar_format()) + | |||||
| scale_x_continuous(labels = scales::dollar_format()) + | |||||
| scale_fill_pomological() | scale_fill_pomological() | ||||
| stacked_bar_plot + theme_pomological("Homemade Apple", 16) | stacked_bar_plot + theme_pomological("Homemade Apple", 16) | ||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ``` r | ``` r | ||||
| paint_pomological( | paint_pomological( | ||||
| stacked_bar_plot + theme_pomological_fancy(), | |||||
| stacked_bar_plot + theme_pomological_fancy("Homemade Apple"), | |||||
| res = 110 | res = 110 | ||||
| ) | ) | ||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ### Density Plot | ### Density Plot | ||||
| density_plot + theme_pomological("Homemade Apple", 16) | density_plot + theme_pomological("Homemade Apple", 16) | ||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ``` r | ``` r | ||||
| ) | ) | ||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ### Points and lines | ### Points and lines | ||||
| full_bar_stack_plot + theme_pomological("Homemade Apple", 16) | full_bar_stack_plot + theme_pomological("Homemade Apple", 16) | ||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ``` r | ``` r | ||||
| ) | ) | ||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| ### One last plot | ### One last plot | ||||
| #> Picking joint bandwidth of 0.057 | #> Picking joint bandwidth of 0.057 | ||||
| ``` | ``` | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| 1. U.S. Department of Agriculture Pomological Watercolor Collection. | 1. U.S. Department of Agriculture Pomological Watercolor Collection. | ||||
| Rare and Special Collections, National Agricultural Library, | Rare and Special Collections, National Agricultural Library, |
| 26.75 22.15 1 | |||||
| 29.8 22.15 1 | |||||
| 31.55 21.1 1 | |||||
| 27.7 20.85 1 | |||||
| 29.9 19.95 1 | |||||
| 26.8 19.05 1 | |||||
| 28.35 18.25 1 | |||||
| 30.4 17.85 1 | |||||
| 27.25 16.7 1 | |||||
| 29.05 16 1 | |||||
| 27.15 14.85 1 | |||||
| 28.2 13.95 1 | |||||
| 30.35 13.85 1 | |||||
| 27.25 11.95 1 | |||||
| 29.45 12.05 1 | |||||
| 31.55 12.2 1 | |||||
| 33.05 10.65 1 | |||||
| 29.95 9.85 1 | |||||
| 28 9.75 1 | |||||
| 27.15 7.85 1 | |||||
| 29.15 8.1 1 | |||||
| 31.95 8.6 1 | |||||
| 34.7 8.55 1 | |||||
| 34.8 12.25 1 | |||||
| 36.3 15.25 1 | |||||
| 36.6 13.2 1 | |||||
| 38.7 14.25 1 | |||||
| 40.3 15.5 1 | |||||
| 42.25 14.25 1 | |||||
| 40.7 12.8 1 | |||||
| 38.6 12.1 1 | |||||
| 36.1 10.5 1 | |||||
| 38.35 10.4 1 | |||||
| 37.65 8.4 1 | |||||
| 40.15 8.55 1 | |||||
| 40.8 10.65 1 | |||||
| 42.9 11.25 1 | |||||
| 41.95 8.5 1 | |||||
| 42.45 17.45 1 | |||||
| 40.25 18.45 1 | |||||
| 42.55 19.45 1 | |||||
| 40.95 20.65 1 | |||||
| 42.25 22.15 1 | |||||
| 38.85 22.4 1 | |||||
| 38.4 20 1 | |||||
| 35.25 20.2 1 | |||||
| 33.25 21 1 | |||||
| 34.15 22.35 1 | |||||
| 35.55 22.5 1 | |||||
| 36.55 21.4 1 | |||||
| 33.35 19.6 2 | |||||
| 32.85 19.55 2 | |||||
| 32.4 19.15 2 | |||||
| 32.45 18.7 2 | |||||
| 32.8 18.9 2 | |||||
| 33.2 19.2 2 | |||||
| 33.7 19.05 2 | |||||
| 33.4 18.75 2 | |||||
| 33.05 18.5 2 | |||||
| 32.8 18.2 2 | |||||
| 34 18.7 2 | |||||
| 33.85 18.25 2 | |||||
| 33.35 18.15 2 | |||||
| 32.8 17.7 2 | |||||
| 33.15 17.55 2 | |||||
| 33.75 17.75 2 | |||||
| 34.15 17.85 2 | |||||
| 34.35 18.35 2 | |||||
| 34.95 18.5 2 | |||||
| 34.75 18.05 2 | |||||
| 35.15 18.05 2 | |||||
| 35.65 18.15 2 | |||||
| 35.45 18.7 2 | |||||
| 36.05 18.75 2 | |||||
| 36.25 18.2 2 | |||||
| 36.6 18.7 2 | |||||
| 37.1 18.5 2 | |||||
| 36.75 18.1 2 | |||||
| 37.65 18.3 2 | |||||
| 37.15 17.85 2 | |||||
| 37.65 17.75 2 | |||||
| 38.05 18.1 2 | |||||
| 38.45 17.7 2 | |||||
| 38.8 17.3 2 | |||||
| 38.2 17.25 2 | |||||
| 38.6 16.8 2 | |||||
| 38.25 16.35 2 | |||||
| 37.9 16.85 2 | |||||
| 37.5 17.3 2 | |||||
| 37.65 16.4 2 | |||||
| 37.15 16.7 2 | |||||
| 37 17.15 2 | |||||
| 36.6 17.4 2 | |||||
| 36.15 17.55 2 | |||||
| 35.75 17.65 2 | |||||
| 36.6 16.9 2 | |||||
| 36.05 16.95 2 | |||||
| 35.45 17 2 | |||||
| 35.3 17.55 2 | |||||
| 34.9 17 2 | |||||
| 34.75 17.45 2 | |||||
| 34.3 17.35 2 | |||||
| 34.3 16.8 2 | |||||
| 33.9 17.2 2 | |||||
| 33.35 17.05 2 | |||||
| 32.85 16.95 2 | |||||
| 33.55 16.6 2 | |||||
| 34 16.4 2 | |||||
| 32.45 17.2 2 | |||||
| 32.1 16.85 2 | |||||
| 31.7 16.65 2 | |||||
| 31.2 16.35 2 | |||||
| 30.95 15.75 2 | |||||
| 31.15 15.35 2 | |||||
| 31.45 15.1 2 | |||||
| 31.75 14.7 2 | |||||
| 32.15 14.35 2 | |||||
| 32.65 14.15 2 | |||||
| 33.15 14.05 2 | |||||
| 33.8 13.9 2 | |||||
| 34.35 14.2 2 | |||||
| 34.3 14.85 2 | |||||
| 34.05 15.35 2 | |||||
| 33.9 15.95 2 | |||||
| 33.35 16.05 2 | |||||
| 33 16.5 2 | |||||
| 32.45 16.6 2 | |||||
| 31.95 16.25 2 | |||||
| 31.5 15.85 2 | |||||
| 31.75 15.4 2 | |||||
| 32.15 15.8 2 | |||||
| 32.55 16.1 2 | |||||
| 32.9 15.7 2 | |||||
| 32.55 15.4 2 | |||||
| 32.05 15.2 2 | |||||
| 32.5 14.8 2 | |||||
| 33 15.25 2 | |||||
| 33.5 15.6 2 | |||||
| 33.6 15.05 2 | |||||
| 32.9 14.7 2 | |||||
| 33.3 14.5 2 | |||||
| 33.8 14.5 2 | |||||
| 9.2 22.35 3 | |||||
| 10.9 22.35 3 | |||||
| 12.45 22.3 3 | |||||
| 13.95 22.05 3 | |||||
| 14.65 20.3 3 | |||||
| 13.15 20.8 3 | |||||
| 11.6 20.95 3 | |||||
| 10.25 21.25 3 | |||||
| 9.2 20.8 3 | |||||
| 8.05 21.55 3 | |||||
| 7.15 19.9 3 | |||||
| 8.55 20 3 | |||||
| 8.5 19.2 3 | |||||
| 7.35 18.3 3 | |||||
| 8.25 16.65 3 | |||||
| 8.95 18 3 | |||||
| 9.6 18.85 3 | |||||
| 9.65 19.75 3 | |||||
| 10.2 20.25 3 | |||||
| 10.9 20.3 3 | |||||
| 12.15 20 3 | |||||
| 11.25 19.75 3 | |||||
| 10.8 19.6 3 | |||||
| 10.4 19.55 3 | |||||
| 10.65 19.35 3 | |||||
| 10.3 19.15 3 | |||||
| 10.95 19.1 3 | |||||
| 10.6 18.85 3 | |||||
| 10.05 18.1 3 | |||||
| 10.35 16.9 3 | |||||
| 10.05 15.9 3 | |||||
| 11.15 18.1 3 | |||||
| 12.1 18.75 3 | |||||
| 13.2 19.2 3 | |||||
| 11.5 17.1 3 | |||||
| 12.65 17.65 3 | |||||
| 14.45 18.35 4 | |||||
| 13.9 16.7 3 | |||||
| 12.6 15.8 3 | |||||
| 15.95 20.75 4 | |||||
| 16.95 21.6 4 | |||||
| 17.9 21.95 4 | |||||
| 19 22.7 4 | |||||
| 20.45 22.75 4 | |||||
| 19.1 21.7 4 | |||||
| 20.4 21.4 4 | |||||
| 21.95 21.9 4 | |||||
| 18.65 20.7 4 | |||||
| 17.75 20.55 4 | |||||
| 17.05 19.85 4 | |||||
| 15.75 19.45 4 | |||||
| 15.75 18.25 4 | |||||
| 16.35 16.9 4 | |||||
| 17.2 15.9 4 | |||||
| 17.9 17 4 | |||||
| 17.3 17.75 4 | |||||
| 17 18.9 4 | |||||
| 17.8 18.65 4 | |||||
| 17.85 19.5 4 | |||||
| 18.5 19.9 4 | |||||
| 19.1 19.95 4 | |||||
| 19.55 20.55 4 | |||||
| 20.1 19.9 4 | |||||
| 19.55 19.3 4 | |||||
| 18.95 19.3 4 | |||||
| 18.55 19.2 4 | |||||
| 18.45 18.85 4 | |||||
| 18.85 18.9 4 | |||||
| 19.2 18.8 4 | |||||
| 18.75 18.55 4 | |||||
| 18.3 18.1 4 | |||||
| 19.1 17.8 4 | |||||
| 19 16.75 4 | |||||
| 18.75 15.5 4 | |||||
| 19.65 18.2 4 | |||||
| 20.1 18.95 4 | |||||
| 21.25 20.4 4 | |||||
| 21.45 19 4 | |||||
| 20.9 17.9 4 | |||||
| 20.25 17.2 4 | |||||
| 20.1 15.4 4 | |||||
| 21.4 15.95 4 | |||||
| 22.2 17.15 4 | |||||
| 11.4 12.55 5 | |||||
| 12.05 12.75 5 | |||||
| 12.7 13 5 | |||||
| 13.35 13.05 5 | |||||
| 14.2 12.95 5 | |||||
| 15.05 12.95 5 | |||||
| 15.6 12.95 5 | |||||
| 16.1 13.1 5 | |||||
| 15.95 12.6 5 | |||||
| 15.4 12.45 5 | |||||
| 14.65 12.4 5 | |||||
| 13.85 12.4 5 | |||||
| 13.15 12.2 5 | |||||
| 12.65 12.4 5 | |||||
| 11.9 12.1 5 | |||||
| 12 11.5 5 | |||||
| 12.65 11.65 5 | |||||
| 13.4 11.65 5 | |||||
| 14.1 11.7 5 | |||||
| 14.6 11.8 5 | |||||
| 15.2 11.95 5 | |||||
| 15.05 11.55 5 | |||||
| 14.45 11.2 5 | |||||
| 13.95 10.9 5 | |||||
| 13.05 11.1 5 | |||||
| 13.55 10.65 5 | |||||
| 12.45 10.9 5 | |||||
| 13.2 10.25 5 | |||||
| 11.25 11.1 5 | |||||
| 11.25 11.85 5 | |||||
| 10.7 12.25 5 | |||||
| 10.05 11.85 5 | |||||
| 10.6 11.6 5 | |||||
| 9.75 11.35 5 | |||||
| 10.4 10.9 5 | |||||
| 9.75 10.6 5 | |||||
| 9.75 9.8 5 | |||||
| 10.35 10.2 5 | |||||
| 10.9 10.4 5 | |||||
| 11.7 10.55 5 | |||||
| 12.4 10.1 5 | |||||
| 12.9 9.7 5 | |||||
| 12.35 9.65 5 | |||||
| 11.85 10 5 | |||||
| 11.15 9.8 5 | |||||
| 10.65 9.55 5 | |||||
| 10.1 9.25 5 | |||||
| 10.75 9 5 | |||||
| 11.1 9.3 5 | |||||
| 11.7 9.4 5 | |||||
| 12.15 9.1 5 | |||||
| 12.85 9.05 5 | |||||
| 12.45 8.7 5 | |||||
| 11.95 8.25 5 | |||||
| 11.7 8.85 5 | |||||
| 11.3 8.5 5 | |||||
| 11.55 7.95 5 | |||||
| 12.9 8.5 5 | |||||
| 13.25 8.05 5 | |||||
| 12.65 7.95 5 | |||||
| 12.1 7.6 5 | |||||
| 11.65 7.35 5 | |||||
| 12.2 7 5 | |||||
| 11.8 6.65 5 | |||||
| 12.65 7.3 5 | |||||
| 13.2 7.55 5 | |||||
| 13.65 7.75 5 | |||||
| 14.35 7.55 5 | |||||
| 13.8 7.3 5 | |||||
| 13.35 6.85 5 | |||||
| 12.7 6.7 5 | |||||
| 12.45 6.25 5 | |||||
| 13.2 5.85 5 | |||||
| 13.65 6.25 5 | |||||
| 14.1 6.75 5 | |||||
| 14.7 6.9 5 | |||||
| 15 7.5 5 | |||||
| 15.85 7.3 5 | |||||
| 15.35 7.05 5 | |||||
| 15.1 6.35 5 | |||||
| 14.45 6.3 5 | |||||
| 14.75 5.75 5 | |||||
| 13.95 5.8 5 | |||||
| 15.5 5.9 5 | |||||
| 15.8 6.4 5 | |||||
| 16.05 6.85 5 | |||||
| 16.55 7.1 5 | |||||
| 16.7 6.5 5 | |||||
| 16.25 6.1 5 | |||||
| 17.05 6.25 5 | |||||
| 15.85 11.55 5 | |||||
| 15.9 12.1 5 | |||||
| 16.3 11.65 5 | |||||
| 16.55 12.05 5 | |||||
| 16.5 12.6 5 | |||||
| 16.75 13.1 5 | |||||
| 17.5 13 5 | |||||
| 17.15 12.65 5 | |||||
| 17.1 12.1 5 | |||||
| 16.9 11.7 5 | |||||
| 17.4 11.65 5 | |||||
| 17.55 12.1 5 | |||||
| 17.75 12.65 5 | |||||
| 18.3 12.75 5 | |||||
| 18.25 12.25 5 | |||||
| 18 11.95 5 | |||||
| 17.85 11.5 5 | |||||
| 18.3 11.65 5 | |||||
| 18.6 12 5 | |||||
| 18.85 12.45 5 | |||||
| 19.1 11.8 5 | |||||
| 18.85 11.45 5 | |||||
| 18.5 11.15 5 | |||||
| 18.95 10.8 5 | |||||
| 19.3 11.15 5 | |||||
| 19.4 10.7 5 | |||||
| 19.25 10.35 5 | |||||
| 19.9 10.6 5 | |||||
| 19.65 10.15 5 | |||||
| 19.45 9.75 5 | |||||
| 19.9 9.45 5 | |||||
| 20.3 10.05 5 | |||||
| 20.65 10.35 5 | |||||
| 21.25 10.1 5 | |||||
| 20.9 9.9 5 | |||||
| 21.65 9.65 5 | |||||
| 21.15 9.35 5 | |||||
| 20.5 9.4 5 | |||||
| 19.5 9.2 5 | |||||
| 19.95 8.85 5 | |||||
| 20.65 8.8 5 | |||||
| 21.2 8.7 5 | |||||
| 21.9 8.85 5 | |||||
| 21.75 8.25 5 | |||||
| 21.65 7.8 5 | |||||
| 21.05 8 5 | |||||
| 20.3 8.2 5 | |||||
| 19.4 8.7 5 | |||||
| 19.6 8.05 5 | |||||
| 18.95 8.1 5 | |||||
| 20 7.6 5 | |||||
| 20.55 7.55 5 | |||||
| 21.25 7.25 5 | |||||
| 20.85 6.85 5 | |||||
| 20.25 7.05 5 | |||||
| 19.55 7.05 5 | |||||
| 19.05 7.45 5 | |||||
| 18.35 7.6 5 | |||||
| 17.85 7.3 5 | |||||
| 18.3 7.1 5 | |||||
| 18.95 6.85 5 | |||||
| 19.6 6.25 5 | |||||
| 20.15 6.45 5 | |||||
| 18.8 6.25 5 | |||||
| 18.35 6.55 5 | |||||
| 17.65 6.55 5 | |||||
| 17.25 6.9 5 | |||||
| 17.95 6.2 5 | |||||
| 17.45 9.85 6 | |||||
| 17.2 9.25 6 | |||||
| 17 9.6 6 | |||||
| 17 10.05 6 | |||||
| 16.45 10.1 6 | |||||
| 16.5 9.8 6 | |||||
| 16.6 9.45 6 | |||||
| 16.6 9.05 6 | |||||
| 15.9 9 6 | |||||
| 16.05 9.35 6 | |||||
| 16.05 9.65 6 | |||||
| 15.85 9.95 6 | |||||
| 15.35 9.9 6 | |||||
| 15.6 9.45 6 | |||||
| 15.3 9.15 6 | |||||
| 15.1 9.55 6 |
| \description{ | \description{ | ||||
| This package provides a ggplot2 theme inspired by the | This package provides a ggplot2 theme inspired by the | ||||
| \href{https://usdawatercolors.nal.usda.gov/pom}{USDA Pomological Watercolors collection} | \href{https://usdawatercolors.nal.usda.gov/pom}{USDA Pomological Watercolors collection} | ||||
| and by Aron Atkins's (\href{https://twitter.com/aronatkins]}{@aronatkins}) | |||||
| and by Aron Atkins's (\href{https://twitter.com/aronatkins]}{\@aronatkins}) | |||||
| \href{https://github.com/rstudio/rstudio-conf/tree/master/2018/Fruit_For_Thought--Aron_Atkins}{talk on parameterized RMarkdown} | \href{https://github.com/rstudio/rstudio-conf/tree/master/2018/Fruit_For_Thought--Aron_Atkins}{talk on parameterized RMarkdown} | ||||
| at \href{https://www.rstudio.com/conference/}{rstudio::conf 2018}. | at \href{https://www.rstudio.com/conference/}{rstudio::conf 2018}. | ||||
| } | } |
| \alias{paint_pomological} | \alias{paint_pomological} | ||||
| \title{Paint a ggpomological watercolor} | \title{Paint a ggpomological watercolor} | ||||
| \usage{ | \usage{ | ||||
| paint_pomological(pomo_gg, width = 800, height = 500, pointsize = 16, | |||||
| outfile = NULL, pomological_background = pomological_images("background"), | |||||
| pomological_overlay = pomological_images("overlay"), ...) | |||||
| paint_pomological( | |||||
| pomo_gg, | |||||
| width = 800, | |||||
| height = 500, | |||||
| pointsize = 16, | |||||
| outfile = NULL, | |||||
| pomological_background = pomological_images("background"), | |||||
| pomological_overlay = pomological_images("overlay"), | |||||
| ... | |||||
| ) | |||||
| } | } | ||||
| \arguments{ | \arguments{ | ||||
| \item{pomo_gg}{A pomologically styled ggplot2 object. See \code{\link[=theme_pomological]{theme_pomological()}}} | \item{pomo_gg}{A pomologically styled ggplot2 object. See \code{\link[=theme_pomological]{theme_pomological()}}} | ||||
| \item{pomological_overlay}{Overlay texture. Set to \code{NULL} for no texture.} | \item{pomological_overlay}{Overlay texture. Set to \code{NULL} for no texture.} | ||||
| \item{...}{Arguments passed on to \code{magick::image_graph} | |||||
| \describe{ | |||||
| \item{res}{resolution in pixels} | |||||
| \item{clip}{enable clipping in the device. Because clipping can slow things down | |||||
| \item{...}{ | |||||
| Arguments passed on to \code{\link[magick:image_graph]{magick::image_graph}} | |||||
| \describe{ | |||||
| \item{\code{res}}{resolution in pixels} | |||||
| \item{\code{clip}}{enable clipping in the device. Because clipping can slow things down | |||||
| a lot, you can disable it if you don't need it.} | a lot, you can disable it if you don't need it.} | ||||
| \item{antialias}{TRUE/FALSE: enables anti-aliasing for text and strokes} | |||||
| }} | |||||
| \item{\code{antialias}}{TRUE/FALSE: enables anti-aliasing for text and strokes} | |||||
| }} | |||||
| } | } | ||||
| \description{ | \description{ | ||||
| Uses \link{magick} to paint a pomological watercolor. (Paints your plot onto a | Uses \link{magick} to paint a pomological watercolor. (Paints your plot onto a |
| scale_fill_pomological(...) | scale_fill_pomological(...) | ||||
| } | } | ||||
| \arguments{ | \arguments{ | ||||
| \item{...}{Arguments passed on to \code{ggplot2::discrete_scale} | |||||
| \describe{ | |||||
| \item{aesthetics}{The names of the aesthetics that this scale works with} | |||||
| \item{scale_name}{The name of the scale} | |||||
| \item{palette}{A palette function that when called with a single integer | |||||
| \item{...}{ | |||||
| Arguments passed on to \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale}} | |||||
| \describe{ | |||||
| \item{\code{aesthetics}}{The names of the aesthetics that this scale works with.} | |||||
| \item{\code{scale_name}}{The name of the scale that should be used for error messages | |||||
| associated with this scale.} | |||||
| \item{\code{palette}}{A palette function that when called with a single integer | |||||
| argument (the number of levels in the scale) returns the values that | argument (the number of levels in the scale) returns the values that | ||||
| they should take} | |||||
| \item{name}{The name of the scale. Used as axis or legend title. If | |||||
| they should take (e.g., \code{\link[scales:hue_pal]{scales::hue_pal()}}).} | |||||
| \item{\code{name}}{The name of the scale. Used as the axis or legend title. If | |||||
| \code{waiver()}, the default, the name of the scale is taken from the first | \code{waiver()}, the default, the name of the scale is taken from the first | ||||
| mapping used for that aesthetic. If \code{NULL}, the legend title will be | mapping used for that aesthetic. If \code{NULL}, the legend title will be | ||||
| omitted.} | omitted.} | ||||
| \item{breaks}{One of: | |||||
| \item{\code{breaks}}{One of: | |||||
| \itemize{ | \itemize{ | ||||
| \item \code{NULL} for no breaks | \item \code{NULL} for no breaks | ||||
| \item \code{waiver()} for the default breaks computed by the | |||||
| transformation object | |||||
| \item \code{waiver()} for the default breaks (the scale limits) | |||||
| \item A character vector of breaks | \item A character vector of breaks | ||||
| \item A function that takes the limits as input and returns breaks | \item A function that takes the limits as input and returns breaks | ||||
| as output | as output | ||||
| }} | }} | ||||
| \item{labels}{One of: | |||||
| \item{\code{labels}}{One of: | |||||
| \itemize{ | \itemize{ | ||||
| \item \code{NULL} for no labels | \item \code{NULL} for no labels | ||||
| \item \code{waiver()} for the default labels computed by the | \item \code{waiver()} for the default labels computed by the | ||||
| \item A function that takes the breaks as input and returns labels | \item A function that takes the breaks as input and returns labels | ||||
| as output | as output | ||||
| }} | }} | ||||
| \item{limits}{A character vector that defines possible values of the scale | |||||
| \item{\code{limits}}{A character vector that defines possible values of the scale | |||||
| and their order.} | and their order.} | ||||
| \item{expand}{Vector of range expansion constants used to add some | |||||
| padding around the data, to ensure that they are placed some distance | |||||
| away from the axes. Use the convenience function \code{\link[=expand_scale]{expand_scale()}} | |||||
| \item{\code{expand}}{For position scales, a vector of range expansion constants used to add some | |||||
| padding around the data to ensure that they are placed some distance | |||||
| away from the axes. Use the convenience function \code{\link[ggplot2:expansion]{expansion()}} | |||||
| to generate the values for the \code{expand} argument. The defaults are to | to generate the values for the \code{expand} argument. The defaults are to | ||||
| expand the scale by 5\% on each side for continuous variables, and by | expand the scale by 5\% on each side for continuous variables, and by | ||||
| 0.6 units on each side for discrete variables.} | 0.6 units on each side for discrete variables.} | ||||
| \item{na.translate}{Unlike continuous scales, discrete scales can easily show | |||||
| \item{\code{na.translate}}{Unlike continuous scales, discrete scales can easily show | |||||
| missing values, and do so by default. If you want to remove missing values | missing values, and do so by default. If you want to remove missing values | ||||
| from a discrete scale, specify \code{na.translate = FALSE}.} | from a discrete scale, specify \code{na.translate = FALSE}.} | ||||
| \item{na.value}{If \code{na.translate = TRUE}, what value aesthetic | |||||
| \item{\code{na.value}}{If \code{na.translate = TRUE}, what value aesthetic | |||||
| value should missing be displayed as? Does not apply to position scales | value should missing be displayed as? Does not apply to position scales | ||||
| where \code{NA} is always placed at the far right.} | where \code{NA} is always placed at the far right.} | ||||
| \item{drop}{Should unused factor levels be omitted from the scale? | |||||
| \item{\code{drop}}{Should unused factor levels be omitted from the scale? | |||||
| The default, \code{TRUE}, uses the levels that appear in the data; | The default, \code{TRUE}, uses the levels that appear in the data; | ||||
| \code{FALSE} uses all the levels in the factor.} | \code{FALSE} uses all the levels in the factor.} | ||||
| \item{guide}{A function used to create a guide or its name. See | |||||
| \code{\link[=guides]{guides()}} for more info.} | |||||
| \item{position}{The position of the axis. "left" or "right" for vertical | |||||
| scales, "top" or "bottom" for horizontal scales} | |||||
| \item{super}{The super class to use for the constructed scale} | |||||
| }} | |||||
| \item{\code{guide}}{A function used to create a guide or its name. See | |||||
| \code{\link[ggplot2:guides]{guides()}} for more information.} | |||||
| \item{\code{position}}{For position scales, The position of the axis. | |||||
| \code{left} or \code{right} for y axes, \code{top} or \code{bottom} for x axes.} | |||||
| \item{\code{super}}{The super class to use for the constructed scale} | |||||
| }} | |||||
| } | } | ||||
| \description{ | \description{ | ||||
| Color scales based on the USDA Pomological Watercolors paintings. | Color scales based on the USDA Pomological Watercolors paintings. |
| \alias{theme_pomological_fancy} | \alias{theme_pomological_fancy} | ||||
| \title{Pomological Theme} | \title{Pomological Theme} | ||||
| \usage{ | \usage{ | ||||
| theme_pomological(base_family = NULL, base_size = 11, | |||||
| 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, | |||||
| panel.grid.color = pomological_base$light_line, | panel.grid.color = pomological_base$light_line, | ||||
| panel.grid.linetype = "dashed", | panel.grid.linetype = "dashed", | ||||
| axis.text.color = pomological_base$medium_line, axis.text.size = base_size | |||||
| * 3/4, base_theme = ggplot2::theme_minimal()) | |||||
| axis.text.color = pomological_base$medium_line, | |||||
| axis.text.size = base_size * 3/4, | |||||
| base_theme = ggplot2::theme_minimal() | |||||
| ) | |||||
| theme_pomological_nobg(..., plot.background.color = "transparent") | theme_pomological_nobg(..., plot.background.color = "transparent") | ||||
| theme_pomological_plain(base_family = "", base_size = 11, | |||||
| plot.background.color = "transparent", ...) | |||||
| theme_pomological_plain( | |||||
| base_family = "", | |||||
| base_size = 11, | |||||
| plot.background.color = "transparent", | |||||
| ... | |||||
| ) | |||||
| theme_pomological_fancy(base_family = "Homemade Apple", base_size = 16, ...) | theme_pomological_fancy(base_family = "Homemade Apple", base_size = 16, ...) | ||||
| } | } | ||||
| \examples{ | \examples{ | ||||
| library(ggplot2) | library(ggplot2) | ||||
| basic_iris_plot <- ggplot(iris) + | |||||
| aes(x = Sepal.Length, y = Sepal.Width, color = Species) + | |||||
| # 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) + | geom_point(size = 2) + | ||||
| # with pomological color scale | |||||
| scale_color_pomological() | |||||
| # Pomological Theme | |||||
| basic_iris_plot + | |||||
| theme_pomological() | |||||
| # With fonts (manual) | |||||
| basic_iris_plot + | |||||
| theme_pomological("Homemade Apple", 16) | |||||
| # Or with fancy alias (same as previous) | |||||
| basic_iris_plot + | |||||
| theme_pomological_fancy() | |||||
| # Plain plot without font or background | |||||
| basic_iris_plot + | |||||
| theme_pomological_plain() | |||||
| 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) | |||||
| } | } | ||||
| \references{ | \references{ |
| knitr::opts_chunk$set(echo = TRUE, fig.width=8, fig.height=5) | knitr::opts_chunk$set(echo = TRUE, fig.width=8, fig.height=5) | ||||
| library(ggpomological) | library(ggpomological) | ||||
| library(dplyr) | library(dplyr) | ||||
| pom_examples_path <- if (!exists("README")) "../man/figures/pom-examples.jpg" else "man/figures/pom-examples.jpg" | |||||
| ``` | ``` | ||||
| <!-- Links --> | <!-- Links --> | ||||
| ```{r ggpomological, echo=FALSE, message=FALSE, warning=FALSE} | ```{r ggpomological, echo=FALSE, message=FALSE, warning=FALSE} | ||||
| fruits <- c("Apple", "Apricot", "Banana", "Fig", "Cherry", "Kiwi", "Grape", "Mango", "Papaya", "Orange", "Peach", "Pear") | fruits <- c("Apple", "Apricot", "Banana", "Fig", "Cherry", "Kiwi", "Grape", "Mango", "Papaya", "Orange", "Peach", "Pear") | ||||
| readr::read_tsv("https://cs.joensuu.fi/sipu/datasets/Compound.txt", col_names = FALSE) %>% | |||||
| # https://cs.joensuu.fi/sipu/datasets/Compound.txt | |||||
| readr::read_tsv(system.file("compound.txt", package = "ggpomological"), col_names = FALSE) %>% | |||||
| filter(X3 < 10) %>% | filter(X3 < 10) %>% | ||||
| mutate(X3 = sample(fruits, length(unique(X3)))[X3]) %>% | mutate(X3 = sample(fruits, length(unique(X3)))[X3]) %>% | ||||
| { | { | ||||
| paint_pomological(res = 110) | paint_pomological(res = 110) | ||||
| ``` | ``` | ||||
| `r knitr::include_graphics(here::here("Readme_files/pom-examples.jpg"))`^[U.S. Department of Agriculture Pomological Watercolor Collection. Rare and Special Collections, National Agricultural Library, Beltsville, MD 20705] | |||||
| `r knitr::include_graphics(pom_examples_path)`^[U.S. Department of Agriculture Pomological Watercolor Collection. Rare and Special Collections, National Agricultural Library, Beltsville, MD 20705] | |||||
| ## Color Palette | ## Color Palette | ||||
| ### Basic iris plot | ### Basic iris plot | ||||
| ```{r plot-demo} | ```{r plot-demo} | ||||
| # 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 | # Base plot | ||||
| basic_iris_plot <- ggplot(iris) + | |||||
| aes(x = Sepal.Length, y = Sepal.Width, color = Species) + | |||||
| geom_point(size = 2) | |||||
| basic_msleep_plot <- ggplot(msleep) + | |||||
| aes(x = sleep_rem, y = sleep_total, color = vore) + | |||||
| geom_point(size = 2) + | |||||
| labs(color = NULL) | |||||
| # Just your standard Iris plot | |||||
| basic_iris_plot | |||||
| # Just your standard ggplot | |||||
| basic_msleep_plot | |||||
| # With pomological colors | # With pomological colors | ||||
| basic_iris_plot <- basic_iris_plot + scale_color_pomological() | |||||
| basic_iris_plot | |||||
| basic_msleep_plot <- basic_msleep_plot + scale_color_pomological() | |||||
| basic_msleep_plot | |||||
| # With pomological theme | # With pomological theme | ||||
| basic_iris_plot + theme_pomological() | |||||
| basic_msleep_plot + theme_pomological() | |||||
| # With transparent background | # With transparent background | ||||
| basic_iris_plot + theme_pomological_plain() | |||||
| basic_msleep_plot + theme_pomological_plain() | |||||
| # Or with "fancy" pomological settings | # Or with "fancy" pomological settings | ||||
| pomological_iris <- basic_iris_plot + theme_pomological_fancy() | |||||
| pomological_msleep <- basic_msleep_plot + theme_pomological_fancy() | |||||
| # Painted! | # Painted! | ||||
| paint_pomological(pomological_iris, res = 110) | |||||
| paint_pomological(pomological_msleep, res = 110) | |||||
| ``` | ``` | ||||
| xlab('Price (USD)') + | xlab('Price (USD)') + | ||||
| ylab('Count') + | ylab('Count') + | ||||
| ggtitle("ggpomological") + | ggtitle("ggpomological") + | ||||
| scale_x_continuous(label = scales::dollar_format()) + | |||||
| scale_x_continuous(labels = scales::dollar_format()) + | |||||
| scale_fill_pomological() | scale_fill_pomological() | ||||
| stacked_bar_plot + theme_pomological("Homemade Apple", 16) | stacked_bar_plot + theme_pomological("Homemade Apple", 16) | ||||
| paint_pomological( | paint_pomological( | ||||
| stacked_bar_plot + theme_pomological_fancy(), | |||||
| stacked_bar_plot + theme_pomological_fancy("Homemade Apple"), | |||||
| res = 110 | res = 110 | ||||
| ) | ) | ||||
| ``` | ``` |