Quellcode durchsuchen

A few tweaks here and there

pull/1/head
Garrick Aden-Buie vor 8 Jahren
Ursprung
Commit
e4ade7fd39
16 geänderte Dateien mit 63 neuen und 38 gelöschten Zeilen
  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 Datei anzeigen

@@ -1,5 +1,5 @@
Package: ggpomological
Version: 0.0.0.9001
Version: 0.1.0
Title: Pomological plot themes for ggplot2
Description: Pomological plot themes and scales for ggplot2 (in progress)
Authors@R: person("Garrick", "Aden-Buie", , "g.adenbuie@gmail.com", c("aut", "cre"))

+ 23
- 13
R/theme_pomological.R Datei anzeigen

@@ -4,7 +4,12 @@
#'
#' @references https://usdawatercolors.nal.usda.gov/pom
#' @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 plot.background.color Color of plot background, passed to `plot.background`
#' @param panel.border.color Color of plot panel border
@@ -22,7 +27,8 @@
#' Visit the links below to install on your system.
#'
#' - [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/)
#'
#' Fonts with R are notoriously tricky, so these may not work well for you. If
@@ -58,8 +64,8 @@
#'
#' @export
theme_pomological <- function(
base_family = 'Homemade Apple',
base_size = 16,
base_family = "Homemade Apple",
base_size = 14,
text.color = pomological_base$dark_blue,
plot.background.color = pomological_base$paper,
panel.border.color = pomological_base$light_line,
@@ -67,7 +73,7 @@ theme_pomological <- function(
panel.grid.color = pomological_base$light_line,
panel.grid.linetype = "dashed",
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()
) {
if (!is.null(base_family)) check_font(base_family)
@@ -120,10 +126,11 @@ theme_pomological_plain <- function(...) {
}

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(
"https://fonts.google.com/specimen/Mr+De+Haviland",
"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/"
)
)
@@ -131,16 +138,19 @@ font_urls <- data.frame(
check_font <- function(font_name) {
if (!requireNamespace("extrafont", quietly = TRUE)) {
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 {
if (!font_name %in% extrafont::fonts()) {
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 {
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 Datei anzeigen

@@ -69,8 +69,9 @@ There are three theme-generating functions:

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/)
- [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/)

Alternatively, use something like [calligrapher.com](https://www.calligraphr.com/) to create your own handwriting font!
@@ -111,19 +112,21 @@ basic_iris_plot <- ggplot(iris) +
# Just your standard 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()
basic_iris_plot

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

# 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!
paint_pomological(pomological_iris, res = 110) %>%
@@ -141,6 +144,7 @@ stacked_bar_plot <- ggplot(diamonds) +
geom_histogram(binwidth = 850) +
xlab('Price (USD)') +
ylab('Count') +
ggtitle("ggpomological") +
scale_x_continuous(label = scales::dollar_format()) +
scale_fill_pomological()


+ 14
- 10
Readme.md Datei anzeigen

@@ -67,8 +67,9 @@ There are three theme-generating functions:
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/)
- [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/)

Alternatively, use something like
@@ -119,27 +120,29 @@ basic_iris_plot
![](Readme_files/figure-gfm/plot-demo-1.png)<!-- -->

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

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

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

# 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)<!-- -->

``` 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)<!-- -->
@@ -160,6 +163,7 @@ stacked_bar_plot <- ggplot(diamonds) +
geom_histogram(binwidth = 850) +
xlab('Price (USD)') +
ylab('Count') +
ggtitle("ggpomological") +
scale_x_continuous(label = scales::dollar_format()) +
scale_fill_pomological()


BIN
Readme_files/figure-gfm/plot-bar-chart-1.png Datei anzeigen

Vorher Nachher
Breite: 768  |  Höhe: 480  |  Größe: 36KB Breite: 768  |  Höhe: 480  |  Größe: 38KB

BIN
Readme_files/figure-gfm/plot-bar-chart-painted.png Datei anzeigen

Vorher Nachher
Breite: 800  |  Höhe: 500  |  Größe: 531KB Breite: 800  |  Höhe: 500  |  Größe: 531KB

BIN
Readme_files/figure-gfm/plot-demo-2.png Datei anzeigen

Vorher Nachher
Breite: 768  |  Höhe: 480  |  Größe: 57KB Breite: 768  |  Höhe: 480  |  Größe: 48KB

BIN
Readme_files/figure-gfm/plot-demo-3.png Datei anzeigen

Vorher Nachher
Breite: 768  |  Höhe: 480  |  Größe: 58KB Breite: 768  |  Höhe: 480  |  Größe: 53KB

BIN
Readme_files/figure-gfm/plot-demo-4.png Datei anzeigen

Vorher Nachher
Breite: 768  |  Höhe: 480  |  Größe: 44KB Breite: 768  |  Höhe: 480  |  Größe: 43KB

BIN
Readme_files/figure-gfm/plot-demo-painted.png Datei anzeigen

Vorher Nachher
Breite: 800  |  Höhe: 500  |  Größe: 539KB Breite: 800  |  Höhe: 500  |  Größe: 534KB

BIN
Readme_files/figure-gfm/plot-density-1.png Datei anzeigen

Vorher Nachher
Breite: 768  |  Höhe: 480  |  Größe: 51KB Breite: 768  |  Höhe: 480  |  Größe: 47KB

BIN
Readme_files/figure-gfm/plot-density-demo-painted.png Datei anzeigen

Vorher Nachher
Breite: 800  |  Höhe: 500  |  Größe: 520KB Breite: 800  |  Höhe: 500  |  Größe: 515KB

BIN
Readme_files/figure-gfm/plot-full-bar-stack-1.png Datei anzeigen

Vorher Nachher
Breite: 768  |  Höhe: 480  |  Größe: 52KB Breite: 768  |  Höhe: 480  |  Größe: 48KB

BIN
Readme_files/figure-gfm/plot-full-bar-stack-painted.png Datei anzeigen

Vorher Nachher
Breite: 800  |  Höhe: 500  |  Größe: 526KB Breite: 800  |  Höhe: 500  |  Größe: 509KB

BIN
Readme_files/figure-gfm/plot-ridges-painted.png Datei anzeigen

Vorher Nachher
Breite: 800  |  Höhe: 500  |  Größe: 529KB Breite: 800  |  Höhe: 500  |  Größe: 528KB

+ 11
- 4
man/theme_pomological.Rd Datei anzeigen

@@ -6,21 +6,27 @@
\alias{theme_pomological_plain}
\title{Pomological Theme}
\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,
plot.background.color = pomological_base$paper,
panel.border.color = pomological_base$light_line, with.panel.grid = FALSE,
panel.grid.color = pomological_base$light_line,
panel.grid.linetype = "dashed",
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_plain(...)
}
\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})}

@@ -57,7 +63,8 @@ The following fonts from \href{https://fonts.google.com}{Google Fonts} work well
Visit the links below to install on your system.
\itemize{
\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}
}


Laden…
Abbrechen
Speichern