Browse Source

x/y scales update to conform to new ggplot2

tags/0.8.0
boB Rudis 4 years ago
parent
commit
236da2c29b
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 6
      DESCRIPTION
  2. 4
      NEWS.md
  3. 110
      R/scales.r
  4. 2
      man/flush_ticks.Rd
  5. 12
      man/scale_ft.Rd
  6. 12
      man/scale_ipsum.Rd
  7. 22
      man/scale_x_percent.Rd
  8. 2
      man/theme_ipsum.Rd
  9. 2
      man/theme_ipsum_es.Rd
  10. 2
      man/theme_ipsum_ps.Rd
  11. 2
      man/theme_ipsum_pub.Rd
  12. 2
      man/theme_ipsum_rc.Rd
  13. 2
      man/theme_ipsum_tw.Rd

6
DESCRIPTION

@ -1,8 +1,8 @@
Package: hrbrthemes
Type: Package
Title: Additional Themes, Theme Components and Utilities for 'ggplot2'
Version: 0.7.2
Date: 2019-08-08
Version: 0.8.0
Date: 2020-02-25
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640")),
@ -57,5 +57,5 @@ Imports:
tools,
magrittr,
gdtools
RoxygenNote: 7.0.0
RoxygenNote: 7.0.2
VignetteBuilder: knitr

4
NEWS.md

@ -1,3 +1,7 @@
# hrbrthemes 0.8.0
- Changes to conform to forthcoming {ggplot2} release
# hrbrthemes 0.7.2
- Further enhancements to the `scale_[xy]_… functions` to support passing in

110
R/scales.r

@ -45,13 +45,26 @@ is.formula <- function (x) { inherits(x, "formula") }
#' scales, "top" or "bottom" for horizontal scales
#' @param sec.axis specify a secondary axis
#' @export
scale_x_percent <- function(name = waiver(), breaks = waiver(),
scale_x_percent <- function(name = waiver(),
breaks = waiver(),
minor_breaks = waiver(),
limits = NULL, expand = c(0.01,0), oob = censor,
na.value = NA_real_, trans = "identity",
position = "bottom", sec.axis = waiver(), labels,
accuracy = 1, scale = 100, prefix = "", suffix = "%",
big.mark = " ", decimal.mark = ".", trim = TRUE, ...) {
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL,
expand = c(0.01,0),
oob = censor,
na.value = NA_real_,
trans = "identity",
position = "bottom",
sec.axis = waiver(),
accuracy = 1,
scale = 100,
prefix = "",
suffix = "%",
big.mark = " ",
decimal.mark = ".",
trim = TRUE, ...) {
if (missing(labels)) {
scales::percent_format(
@ -69,12 +82,13 @@ scale_x_percent <- function(name = waiver(), breaks = waiver(),
ggplot2::continuous_scale(
aesthetics = c(
"x", "xmin", "xmax", "xend", "xintercept", "xmin_final",
"xmax_final", "xlower", "xmiddle", "xupper"
"xmax_final", "xlower", "xmiddle", "xupper", "x0"
),
scale_name = "position_c",
palette = identity,
name = name,
breaks = breaks,
n.breaks = n.breaks,
minor_breaks = minor_breaks,
labels = labels,
limits = limits,
@ -82,7 +96,7 @@ scale_x_percent <- function(name = waiver(), breaks = waiver(),
oob = oob,
na.value = na.value,
trans = trans,
guide = "none",
guide = guide,
position = position,
super = ScaleContinuousPosition
) -> sc
@ -102,13 +116,26 @@ scale_x_percent <- function(name = waiver(), breaks = waiver(),
#' @rdname scale_x_percent
#' @export
scale_y_percent <- function(name = waiver(), breaks = waiver(),
scale_y_percent <- function(name = waiver(),
breaks = waiver(),
minor_breaks = waiver(),
limits = NULL, expand = c(0.01,0), oob = censor,
na.value = NA_real_, trans = "identity",
position = "left", sec.axis = waiver(), labels,
accuracy = 1, scale = 100, prefix = "", suffix = "%",
big.mark = " ", decimal.mark = ".", trim = TRUE, ...) {
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL,
expand = c(0.01,0),
oob = censor,
na.value = NA_real_,
trans = "identity",
position = "left",
sec.axis = waiver(),
accuracy = 1,
scale = 100,
prefix = "",
suffix = "%",
big.mark = " ",
decimal.mark = ".",
trim = TRUE, ...) {
if (missing(labels)) {
scales::percent_format(
@ -132,6 +159,7 @@ scale_y_percent <- function(name = waiver(), breaks = waiver(),
palette = identity,
name = name,
breaks = breaks,
n.breaks = n.breaks,
minor_breaks = minor_breaks,
labels = labels,
limits = limits,
@ -139,7 +167,7 @@ scale_y_percent <- function(name = waiver(), breaks = waiver(),
oob = oob,
na.value = na.value,
trans = trans,
guide = "none",
guide = guide,
position = position,
super = ScaleContinuousPosition
) -> sc
@ -162,14 +190,26 @@ scale_y_percent <- function(name = waiver(), breaks = waiver(),
#' [scales::comma_format()] or [scales::percent_format()]
#' @param ... passed on to [scales::comma_format()] or [scales::percent_format()]
#' @export
scale_x_comma <- function(name = waiver(), breaks = waiver(),
scale_x_comma <- function(name = waiver(),
breaks = waiver(),
minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL,
expand = c(0.01,0), oob = censor,
na.value = NA_real_, trans = "identity",
position = "bottom", sec.axis = waiver(), labels,
accuracy = 1, scale = 1, prefix = "", suffix = "",
big.mark = ",", decimal.mark = ".", trim = TRUE,
expand = c(0.01,0),
oob = censor,
na.value = NA_real_,
trans = "identity",
position = "bottom",
sec.axis = waiver(),
accuracy = 1,
scale = 1,
prefix = "",
suffix = "",
big.mark = ",",
decimal.mark = ".",
trim = TRUE,
...) {
if (missing(labels)) {
@ -195,6 +235,7 @@ scale_x_comma <- function(name = waiver(), breaks = waiver(),
palette = identity,
name = name,
breaks = breaks,
n.breaks = n.breaks,
minor_breaks = minor_breaks,
labels = labels,
limits = limits,
@ -202,7 +243,7 @@ scale_x_comma <- function(name = waiver(), breaks = waiver(),
oob = oob,
na.value = na.value,
trans = trans,
guide = "none",
guide = guide,
position = position,
super = ScaleContinuousPosition
) -> sc
@ -225,11 +266,23 @@ scale_x_comma <- function(name = waiver(), breaks = waiver(),
scale_y_comma <- function(name = waiver(),
breaks = waiver(),
minor_breaks = waiver(),
limits = NULL, expand = c(0.01,0), oob = censor,
na.value = NA_real_, trans = "identity",
position = "left", sec.axis = waiver(), labels,
accuracy = 1, scale = 1, prefix = "", suffix = "",
big.mark = ",", decimal.mark = ".", trim = TRUE,
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL,
expand = c(0.01,0),
oob = censor,
na.value = NA_real_,
trans = "identity",
position = "left",
sec.axis = waiver(),
accuracy = 1,
scale = 1,
prefix = "",
suffix = "",
big.mark = ",",
decimal.mark = ".",
trim = TRUE,
...) {
if (missing(labels)) {
@ -255,6 +308,7 @@ scale_y_comma <- function(name = waiver(),
palette = identity,
name = name,
breaks = breaks,
n.breaks = n.breaks,
minor_breaks = minor_breaks,
labels = labels,
limits = limits,
@ -262,7 +316,7 @@ scale_y_comma <- function(name = waiver(),
oob = oob,
na.value = na.value,
trans = trans,
guide = "none",
guide = guide,
position = position,
super = ScaleContinuousPosition
) -> sc

2
man/flush_ticks.Rd

@ -22,7 +22,7 @@ ggplot2 object with \code{theme()} elements added
A covenience function intended for basic, fixed-scale plots only (i.e. does not handle
free scales in facets).\cr
\cr
You need to pass in a ggplot2 object to this function. It can't be \verb{+}'d in a chain
You need to pass in a ggplot2 object to this function. It can't be \code{+}'d in a chain
of geoms, coords, scales, themes, etc. It also builds the plot (but does not display
it) so if the plt takes a while (i.e. has lots of data or transforms) this will also
take a while.

12
man/scale_ft.Rd

@ -16,11 +16,12 @@ scale_fill_ft(...)
\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}
\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
they should take.}
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
mapping used for that aesthetic. If \code{NULL}, the legend title will be
@ -28,8 +29,7 @@ omitted.}
\item{\code{breaks}}{One of:
\itemize{
\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 function that takes the limits as input and returns breaks
as output
@ -55,7 +55,7 @@ where \code{NA} is always placed at the far right.}
The default, \code{TRUE}, uses the levels that appear in the data;
\code{FALSE} uses all the levels in the factor.}
\item{\code{guide}}{A function used to create a guide or its name. See
\code{\link[=guides]{guides()}} for more info.}
\code{\link[ggplot2:guides]{guides()}} for more information.}
\item{\code{super}}{The super class to use for the constructed scale}
}}
}

12
man/scale_ipsum.Rd

@ -16,11 +16,12 @@ scale_fill_ipsum(...)
\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}
\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
they should take.}
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
mapping used for that aesthetic. If \code{NULL}, the legend title will be
@ -28,8 +29,7 @@ omitted.}
\item{\code{breaks}}{One of:
\itemize{
\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 function that takes the limits as input and returns breaks
as output
@ -55,7 +55,7 @@ where \code{NA} is always placed at the far right.}
The default, \code{TRUE}, uses the levels that appear in the data;
\code{FALSE} uses all the levels in the factor.}
\item{\code{guide}}{A function used to create a guide or its name. See
\code{\link[=guides]{guides()}} for more info.}
\code{\link[ggplot2:guides]{guides()}} for more information.}
\item{\code{super}}{The super class to use for the constructed scale}
}}
}

22
man/scale_x_percent.Rd

@ -11,6 +11,9 @@ scale_x_percent(
name = waiver(),
breaks = waiver(),
minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL,
expand = c(0.01, 0),
oob = censor,
@ -18,7 +21,6 @@ scale_x_percent(
trans = "identity",
position = "bottom",
sec.axis = waiver(),
labels,
accuracy = 1,
scale = 100,
prefix = "",
@ -33,6 +35,9 @@ scale_y_percent(
name = waiver(),
breaks = waiver(),
minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL,
expand = c(0.01, 0),
oob = censor,
@ -40,7 +45,6 @@ scale_y_percent(
trans = "identity",
position = "left",
sec.axis = waiver(),
labels,
accuracy = 1,
scale = 100,
prefix = "",
@ -55,6 +59,9 @@ scale_x_comma(
name = waiver(),
breaks = waiver(),
minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL,
expand = c(0.01, 0),
oob = censor,
@ -62,7 +69,6 @@ scale_x_comma(
trans = "identity",
position = "bottom",
sec.axis = waiver(),
labels,
accuracy = 1,
scale = 1,
prefix = "",
@ -77,6 +83,9 @@ scale_y_comma(
name = waiver(),
breaks = waiver(),
minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL,
expand = c(0.01, 0),
oob = censor,
@ -84,7 +93,6 @@ scale_y_comma(
trans = "identity",
position = "left",
sec.axis = waiver(),
labels,
accuracy = 1,
scale = 1,
prefix = "",
@ -120,6 +128,9 @@ each major break)
\item A function that given the limits returns a vector of minor breaks.
}}
\item{labels}{Specifying overrides the default format (i.e. you really don't
want to do that). \code{NULL} means no labels.}
\item{limits}{A numeric vector of length two providing limits of the scale.
Use \code{NA} to refer to the existing minimum or maximum.}
@ -142,9 +153,6 @@ scales, "top" or "bottom" for horizontal scales}
\item{sec.axis}{specify a secondary axis}
\item{labels}{Specifying overrides the default format (i.e. you really don't
want to do that). \code{NULL} means no labels.}
\item{accuracy, scale, prefix, suffix, big.mark, decimal.mark, trim}{See
[scales::comma_format()] or [scales::percent_format()]}

2
man/theme_ipsum.Rd

@ -113,7 +113,7 @@ ggplot(mtcars, aes(mpg, wt)) +
update_geom_font_defaults()
count(mpg, class) %>%
count(mpg, class) \%>\%
ggplot(aes(class, n)) +
geom_col() +
geom_text(aes(label=n), nudge_y=3) +

2
man/theme_ipsum_es.Rd

@ -106,7 +106,7 @@ ggplot(mtcars, aes(mpg, wt)) +
# note: may need to make this font_es on Windows
update_geom_font_defaults(family=font_es_light)
count(mpg, class) %>%
count(mpg, class) \%>\%
ggplot(aes(class, n)) +
geom_col() +
geom_text(aes(label=n), nudge_y=3) +

2
man/theme_ipsum_ps.Rd

@ -103,7 +103,7 @@ ggplot(mtcars, aes(mpg, wt)) +
# note: make this font_rc on Windows
update_geom_font_defaults(family=font_rc_light)
count(mpg, class) %>%
count(mpg, class) \%>\%
ggplot(aes(class, n)) +
geom_col() +
geom_text(aes(label=n), nudge_y=3) +

2
man/theme_ipsum_pub.Rd

@ -103,7 +103,7 @@ ggplot(mtcars, aes(mpg, wt)) +
update_geom_font_defaults(family=font_pub)
count(mpg, class) %>%
count(mpg, class) \%>\%
ggplot(aes(class, n)) +
geom_col() +
geom_text(aes(label=n), nudge_y=3) +

2
man/theme_ipsum_rc.Rd

@ -170,7 +170,7 @@ ggplot(mtcars, aes(mpg, wt)) +
# note: make this font_rc on Windows
update_geom_font_defaults(family=font_rc_light)
count(mpg, class) %>%
count(mpg, class) \%>\%
ggplot(aes(class, n)) +
geom_col() +
geom_text(aes(label=n), nudge_y=3) +

2
man/theme_ipsum_tw.Rd

@ -104,7 +104,7 @@ ggplot(mtcars, aes(mpg, wt)) +
# note: make this font_rc on Windows
update_geom_font_defaults(family=font_rc_light)
count(mpg, class) %>%
count(mpg, class) \%>\%
ggplot(aes(class, n)) +
geom_col() +
geom_text(aes(label=n), nudge_y=3) +

Loading…
Cancel
Save