🍑 Pomological plot theme for ggplot2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
4.4KB

  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/theme_pomological.R
  3. \name{theme_pomological}
  4. \alias{theme_pomological}
  5. \alias{theme_pomological_nobg}
  6. \alias{theme_pomological_plain}
  7. \alias{theme_pomological_fancy}
  8. \title{Pomological Theme}
  9. \usage{
  10. theme_pomological(
  11. base_family = NULL,
  12. base_size = 11,
  13. text.color = pomological_base$dark_blue,
  14. plot.background.color = pomological_base$paper,
  15. panel.border.color = pomological_base$light_line,
  16. with.panel.grid = FALSE,
  17. panel.grid.color = pomological_base$light_line,
  18. panel.grid.linetype = "dashed",
  19. axis.text.color = pomological_base$medium_line,
  20. axis.text.size = base_size * 3/4,
  21. base_theme = ggplot2::theme_minimal()
  22. )
  23. theme_pomological_nobg(..., plot.background.color = "transparent")
  24. theme_pomological_plain(
  25. base_family = "",
  26. base_size = 11,
  27. plot.background.color = "transparent",
  28. ...
  29. )
  30. theme_pomological_fancy(base_family = "Homemade Apple", base_size = 16, ...)
  31. }
  32. \arguments{
  33. \item{base_family}{Base text family. See \strong{Fonts} in \code{\link[=theme_pomological]{theme_pomological()}}
  34. for some examples from Google Fonts options, including \code{"Mr De Haviland"},
  35. \code{"Homemade Apple"}, \code{"Marck Script"}, and \code{"Mr. Bedfort"}. For the
  36. authentic pomological look, use \code{"Homemade Apple"} or \code{"Mr De Haviland"}.
  37. Set to \code{NULL} or use \code{\link[=theme_pomological_plain]{theme_pomological_plain()}} for no change to fonts.}
  38. \item{base_size}{Base text size}
  39. \item{text.color}{Color of all text (except axis text, see \code{axis.text.color})}
  40. \item{plot.background.color}{Color of plot background, passed to \code{plot.background}}
  41. \item{panel.border.color}{Color of plot panel border}
  42. \item{with.panel.grid}{If \code{FALSE} gridlines in plot are removed}
  43. \item{panel.grid.color, panel.grid.linetype}{Color and linetype of panel grid, passed to \code{panel.grid}}
  44. \item{axis.text.color, axis.text.size}{Color and size of axis text}
  45. \item{base_theme}{Starting theme of plot, default is
  46. \code{\link[ggplot2:theme_minimal]{ggplot2::theme_minimal()}}. Any elements set by \code{theme_pomological()} will
  47. overwrite the \code{base_theme} unless the specific parameter is explicitly set
  48. to \code{NULL}.}
  49. }
  50. \description{
  51. \link{ggplot2} plot theme based on the USDA Pomological Watercolors paintings.
  52. }
  53. \section{Functions}{
  54. \itemize{
  55. \item \code{theme_pomological_nobg}: Pomological theme with white (transparent) background
  56. \item \code{theme_pomological_plain}: A "plain" pomological theme with white
  57. background and normal fonts.
  58. \item \code{theme_pomological_fancy}: A "fancy" pomological theme with fancy fonts
  59. }}
  60. \section{Fonts}{
  61. Complete the pomological watercolor theme with a handwriting or cursive font.
  62. The following fonts from \href{https://fonts.google.com}{Google Fonts} work well.
  63. Visit the links below to install on your system.
  64. \itemize{
  65. \item \href{https://fonts.google.com/specimen/Homemade+Apple/}{Homemade Apple}
  66. \item \href{https://fonts.google.com/specimen/Mr+De+Haviland}{Mr. De Haviland}
  67. \item \href{https://fonts.google.com/specimen/Marck+Script/}{Marck Script}
  68. \item \href{https://fonts.google.com/specimen/Mr+Bedfort/}{Mr. Bedfort}
  69. }
  70. Fonts with R are notoriously tricky, so these may not work well for you. If
  71. you have installed the fonts but they aren't showing up or working, you can
  72. always try running \code{extrafont::font_import()} or \code{extrafont::load_fonts()} in
  73. the session or RMarkdown document. Or you can use \code{\link[=theme_pomological_plain]{theme_pomological_plain()}}.
  74. }
  75. \examples{
  76. library(ggplot2)
  77. # Prep msleep data
  78. msleep <- ggplot2::msleep[, c("vore", "sleep_rem", "sleep_total")]
  79. msleep <- msleep[complete.cases(msleep), ]
  80. msleep$vore <- paste0(msleep$vore, "vore")
  81. # Base plot
  82. basic_msleep_plot <- ggplot(msleep) +
  83. aes(x = sleep_rem, y = sleep_total, color = vore) +
  84. geom_point(size = 2) +
  85. labs(color = NULL)
  86. # Just your standard ggplot
  87. basic_msleep_plot
  88. # With pomological colors
  89. basic_msleep_plot <- basic_msleep_plot + scale_color_pomological()
  90. basic_msleep_plot
  91. # With pomological theme
  92. basic_msleep_plot + theme_pomological()
  93. # With transparent background
  94. basic_msleep_plot + theme_pomological_plain()
  95. # Or with "fancy" pomological settings
  96. pomological_msleep <- basic_msleep_plot + theme_pomological_fancy()
  97. # Painted!
  98. paint_pomological(pomological_msleep, res = 110)
  99. }
  100. \references{
  101. https://usdawatercolors.nal.usda.gov/pom
  102. }
  103. \seealso{
  104. \link[ggplot2:theme]{ggplot2::theme}
  105. }