Parcourir la source

A few tweaks here and there

pull/1/head
Garrick Aden-Buie il y a 8 ans
Parent
révision
e4ade7fd39
16 fichiers modifiés avec 63 ajouts et 38 suppressions
  1. +1
    -1
      DESCRIPTION
  2. +23
    -13
      R/theme_pomological.R
  3. +14
    -10
      Readme.Rmd
  4. +14
    -10
      Readme.md
  5. BIN
      Readme_files/figure-gfm/plot-bar-chart-1.png
  6. BIN
      Readme_files/figure-gfm/plot-bar-chart-painted.png
  7. BIN
      Readme_files/figure-gfm/plot-demo-2.png
  8. BIN
      Readme_files/figure-gfm/plot-demo-3.png
  9. BIN
      Readme_files/figure-gfm/plot-demo-4.png
  10. BIN
      Readme_files/figure-gfm/plot-demo-painted.png
  11. BIN
      Readme_files/figure-gfm/plot-density-1.png
  12. BIN
      Readme_files/figure-gfm/plot-density-demo-painted.png
  13. BIN
      Readme_files/figure-gfm/plot-full-bar-stack-1.png
  14. BIN
      Readme_files/figure-gfm/plot-full-bar-stack-painted.png
  15. BIN
      Readme_files/figure-gfm/plot-ridges-painted.png
  16. +11
    -4
      man/theme_pomological.Rd

+ 1
- 1
DESCRIPTION Voir le fichier

Package: ggpomological Package: ggpomological
Version: 0.0.0.9001
Version: 0.1.0
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"))

+ 23
- 13
R/theme_pomological.R Voir le fichier

#' #'
#' @references https://usdawatercolors.nal.usda.gov/pom #' @references https://usdawatercolors.nal.usda.gov/pom
#' @seealso [ggplot2::theme] #' @seealso [ggplot2::theme]
#' @param base_family,base_size Base text family and size
#' @param base_family Base text family. See **Fonts** in [theme_pomological()]
#' for some examples from Google Fonts options, including `"Mr De Haviland"`,
#' `"Homemade Apple"`, `"Marck Script"`, and `"Mr. Bedfort"`. For the
#' authentic pomological look, use `"Homemade Apple"` or `"Mr De Haviland"`.
#' Set to `NULL` or use [theme_pomological_plain()] for no change to fonts.
#' @param base_size Base text size
#' @param text.color Color of all text (except axis text, see `axis.text.color`) #' @param text.color Color of all text (except axis text, see `axis.text.color`)
#' @param plot.background.color Color of plot background, passed to `plot.background` #' @param plot.background.color Color of plot background, passed to `plot.background`
#' @param panel.border.color Color of plot panel border #' @param panel.border.color Color of plot panel border
#' Visit the links below to install on your system. #' Visit the links below to install on your system.
#' #'
#' - [Homemade Apple](https://fonts.google.com/specimen/Homemade+Apple/) #' - [Homemade Apple](https://fonts.google.com/specimen/Homemade+Apple/)
#' - [Amatic SC](https://fonts.google.com/specimen/Amatic+SC/)
#' - [Mr. De Haviland](https://fonts.google.com/specimen/Mr+De+Haviland)
#' - [Marck Script](https://fonts.google.com/specimen/Marck+Script/)
#' - [Mr. Bedfort](https://fonts.google.com/specimen/Mr+Bedfort/) #' - [Mr. Bedfort](https://fonts.google.com/specimen/Mr+Bedfort/)
#' #'
#' Fonts with R are notoriously tricky, so these may not work well for you. If #' Fonts with R are notoriously tricky, so these may not work well for you. If
#' #'
#' @export #' @export
theme_pomological <- function( theme_pomological <- function(
base_family = 'Homemade Apple',
base_size = 16,
base_family = "Homemade Apple",
base_size = 14,
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,
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.color = pomological_base$medium_line,
axis.text.size = base_size * 14/16,
axis.text.size = base_size * 3/4,
base_theme = ggplot2::theme_minimal() base_theme = ggplot2::theme_minimal()
) { ) {
if (!is.null(base_family)) check_font(base_family) if (!is.null(base_family)) check_font(base_family)
} }


font_urls <- data.frame( font_urls <- data.frame(
name = c("Homemade Apple", "Amatic SC", "Mr. Bedfort"),
name = c("Mr De Haviland", "Homemade Apple", "Marck Script", "Mr. Bedfort"),
url = c( url = c(
"https://fonts.google.com/specimen/Mr+De+Haviland",
"https://fonts.google.com/specimen/Homemade+Apple/", "https://fonts.google.com/specimen/Homemade+Apple/",
"https://fonts.google.com/specimen/Amatic+SC/",
"https://fonts.google.com/specimen/Marck+Script/",
"https://fonts.google.com/specimen/Mr+Bedfort/" "https://fonts.google.com/specimen/Mr+Bedfort/"
) )
) )
check_font <- function(font_name) { check_font <- function(font_name) {
if (!requireNamespace("extrafont", quietly = TRUE)) { if (!requireNamespace("extrafont", quietly = TRUE)) {
warning("The font \"", font_name, "\" may or may not be installed on your system.", warning("The font \"", font_name, "\" may or may not be installed on your system.",
"Please install the package `extrafont` if you'd like me to be able to check for you.")
"Please install the package `extrafont` if you'd like me to be able to check for you.",
call. = FALSE)
} else { } else {
if (!font_name %in% extrafont::fonts()) { if (!font_name %in% extrafont::fonts()) {
if (font_name %in% font_urls$name) { if (font_name %in% font_urls$name) {
warning("Unable to find font '", font_name, "'. ",
"If recently installed, please run `extrafonts::font_import()`. ",
"To install, visit: ", font_urls[font_urls$name == font_name, "url"])
warning("Font '", font_name, "' isn't in the extrafonts font list (but it may still work). ",
"If recently installed, you can try running `extrafonts::font_import()`. ",
"To install, visit: ", font_urls[font_urls$name == font_name, "url"],
call. = FALSE)
} else { } else {
warning("Unable to find font '", font_name, "'. ",
"If recently installed, please run `extrafonts::font_import()`. ")
warning("Font '", font_name, "' isn't in the extrafonts font list (but it may still work). ",
"If recently installed, you can try running `extrafonts::font_import()`. ",
call. = FALSE)
} }
} }
} }

+ 14
- 10
Readme.Rmd Voir le fichier



A handwriting font is needed for the fully authentic pomological look, and I found a few from Google Fonts that fit the bill. 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/) - [Homemade Apple](https://fonts.google.com/specimen/Homemade+Apple/)
- [Amatic SC](https://fonts.google.com/specimen/Amatic+SC/)
- [Marck Script](https://fonts.google.com/specimen/Marck+Script/)
- [Mr. Bedfort](https://fonts.google.com/specimen/Mr+Bedfort/) - [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! Alternatively, use something like [calligrapher.com](https://www.calligraphr.com/) to create your own handwriting font!
# Just your standard Iris plot # Just your standard Iris plot
basic_iris_plot basic_iris_plot


# With pomological theme
basic_iris_plot +
theme_pomological() +
# With pomological colors
basic_iris_plot <- basic_iris_plot +
scale_color_pomological() scale_color_pomological()
basic_iris_plot

# With pomological theme
pomological_iris <- basic_iris_plot + theme_pomological()


# With transparent background # With transparent background
pomological_iris <- basic_iris_plot +
theme_pomological_nobg() +
scale_color_pomological()
pomological_iris
basic_iris_plot +
theme_pomological_nobg()


# Without fonts
pomological_iris + theme_pomological_plain()
# Or with "plain" pomological
basic_iris_plot +
theme_pomological_plain()


# Painted! # Painted!
paint_pomological(pomological_iris, res = 110) %>% paint_pomological(pomological_iris, res = 110) %>%
geom_histogram(binwidth = 850) + geom_histogram(binwidth = 850) +
xlab('Price (USD)') + xlab('Price (USD)') +
ylab('Count') + ylab('Count') +
ggtitle("ggpomological") +
scale_x_continuous(label = scales::dollar_format()) + scale_x_continuous(label = scales::dollar_format()) +
scale_fill_pomological() scale_fill_pomological()



+ 14
- 10
Readme.md Voir le fichier

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.


- [Mr. De Haviland](https://fonts.google.com/specimen/Mr+De+Haviland)
- [Homemade Apple](https://fonts.google.com/specimen/Homemade+Apple/) - [Homemade Apple](https://fonts.google.com/specimen/Homemade+Apple/)
- [Amatic SC](https://fonts.google.com/specimen/Amatic+SC/)
- [Marck Script](https://fonts.google.com/specimen/Marck+Script/)
- [Mr. Bedfort](https://fonts.google.com/specimen/Mr+Bedfort/) - [Mr. Bedfort](https://fonts.google.com/specimen/Mr+Bedfort/)


Alternatively, use something like Alternatively, use something like
![](Readme_files/figure-gfm/plot-demo-1.png)<!-- --> ![](Readme_files/figure-gfm/plot-demo-1.png)<!-- -->


``` r ``` r
# With pomological theme
basic_iris_plot +
theme_pomological() +
# With pomological colors
basic_iris_plot <- basic_iris_plot +
scale_color_pomological() scale_color_pomological()
basic_iris_plot
``` ```


![](Readme_files/figure-gfm/plot-demo-2.png)<!-- --> ![](Readme_files/figure-gfm/plot-demo-2.png)<!-- -->


``` r ``` r
# With pomological theme
pomological_iris <- basic_iris_plot + theme_pomological()

# With transparent background # With transparent background
pomological_iris <- basic_iris_plot +
theme_pomological_nobg() +
scale_color_pomological()
pomological_iris
basic_iris_plot +
theme_pomological_nobg()
``` ```


![](Readme_files/figure-gfm/plot-demo-3.png)<!-- --> ![](Readme_files/figure-gfm/plot-demo-3.png)<!-- -->


``` r ``` r
# Without fonts
pomological_iris + theme_pomological_plain()
# Or with "plain" pomological
basic_iris_plot +
theme_pomological_plain()
``` ```


![](Readme_files/figure-gfm/plot-demo-4.png)<!-- --> ![](Readme_files/figure-gfm/plot-demo-4.png)<!-- -->
geom_histogram(binwidth = 850) + geom_histogram(binwidth = 850) +
xlab('Price (USD)') + xlab('Price (USD)') +
ylab('Count') + ylab('Count') +
ggtitle("ggpomological") +
scale_x_continuous(label = scales::dollar_format()) + scale_x_continuous(label = scales::dollar_format()) +
scale_fill_pomological() scale_fill_pomological()



BIN
Readme_files/figure-gfm/plot-bar-chart-1.png Voir le fichier

Before After
Width: 768  |  Height: 480  |  Size: 36KB Width: 768  |  Height: 480  |  Size: 38KB

BIN
Readme_files/figure-gfm/plot-bar-chart-painted.png Voir le fichier

Before After
Width: 800  |  Height: 500  |  Size: 531KB Width: 800  |  Height: 500  |  Size: 531KB

BIN
Readme_files/figure-gfm/plot-demo-2.png Voir le fichier

Before After
Width: 768  |  Height: 480  |  Size: 57KB Width: 768  |  Height: 480  |  Size: 48KB

BIN
Readme_files/figure-gfm/plot-demo-3.png Voir le fichier

Before After
Width: 768  |  Height: 480  |  Size: 58KB Width: 768  |  Height: 480  |  Size: 53KB

BIN
Readme_files/figure-gfm/plot-demo-4.png Voir le fichier

Before After
Width: 768  |  Height: 480  |  Size: 44KB Width: 768  |  Height: 480  |  Size: 43KB

BIN
Readme_files/figure-gfm/plot-demo-painted.png Voir le fichier

Before After
Width: 800  |  Height: 500  |  Size: 539KB Width: 800  |  Height: 500  |  Size: 534KB

BIN
Readme_files/figure-gfm/plot-density-1.png Voir le fichier

Before After
Width: 768  |  Height: 480  |  Size: 51KB Width: 768  |  Height: 480  |  Size: 47KB

BIN
Readme_files/figure-gfm/plot-density-demo-painted.png Voir le fichier

Before After
Width: 800  |  Height: 500  |  Size: 520KB Width: 800  |  Height: 500  |  Size: 515KB

BIN
Readme_files/figure-gfm/plot-full-bar-stack-1.png Voir le fichier

Before After
Width: 768  |  Height: 480  |  Size: 52KB Width: 768  |  Height: 480  |  Size: 48KB

BIN
Readme_files/figure-gfm/plot-full-bar-stack-painted.png Voir le fichier

Before After
Width: 800  |  Height: 500  |  Size: 526KB Width: 800  |  Height: 500  |  Size: 509KB

BIN
Readme_files/figure-gfm/plot-ridges-painted.png Voir le fichier

Before After
Width: 800  |  Height: 500  |  Size: 529KB Width: 800  |  Height: 500  |  Size: 528KB

+ 11
- 4
man/theme_pomological.Rd Voir le fichier

\alias{theme_pomological_plain} \alias{theme_pomological_plain}
\title{Pomological Theme} \title{Pomological Theme}
\usage{ \usage{
theme_pomological(base_family = "Homemade Apple", base_size = 16,
theme_pomological(base_family = "Homemade Apple", base_size = 18,
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 axis.text.color = pomological_base$medium_line, axis.text.size = base_size
* 14/16, base_theme = ggplot2::theme_minimal())
* 3/4, base_theme = ggplot2::theme_minimal())


theme_pomological_nobg(...) theme_pomological_nobg(...)


theme_pomological_plain(...) theme_pomological_plain(...)
} }
\arguments{ \arguments{
\item{base_family, base_size}{Base text family and size}
\item{base_family}{Base text family. See \strong{Fonts} in \code{\link[=theme_pomological]{theme_pomological()}}
for some examples from Google Fonts options, including \code{"Mr De Haviland"},
\code{"Homemade Apple"}, \code{"Marck Script"}, and \code{"Mr. Bedfort"}. For the
authentic pomological look, use \code{"Homemade Apple"} or \code{"Mr De Haviland"}.
Set to \code{NULL} or use \code{\link[=theme_pomological_plain]{theme_pomological_plain()}} for no change to fonts.}

\item{base_size}{Base text size}


\item{text.color}{Color of all text (except axis text, see \code{axis.text.color})} \item{text.color}{Color of all text (except axis text, see \code{axis.text.color})}


Visit the links below to install on your system. Visit the links below to install on your system.
\itemize{ \itemize{
\item \href{https://fonts.google.com/specimen/Homemade+Apple/}{Homemade Apple} \item \href{https://fonts.google.com/specimen/Homemade+Apple/}{Homemade Apple}
\item \href{https://fonts.google.com/specimen/Amatic+SC/}{Amatic SC}
\item \href{https://fonts.google.com/specimen/Mr+De+Haviland}{Mr. De Haviland}
\item \href{https://fonts.google.com/specimen/Marck+Script/}{Marck Script}
\item \href{https://fonts.google.com/specimen/Mr+Bedfort/}{Mr. Bedfort} \item \href{https://fonts.google.com/specimen/Mr+Bedfort/}{Mr. Bedfort}
} }



Chargement…
Annuler
Enregistrer