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

4
NEWS.md

@ -1,3 +1,7 @@
# hrbrthemes 0.8.0
- Changes to conform to forthcoming {ggplot2} release
# hrbrthemes 0.7.2 # hrbrthemes 0.7.2
- Further enhancements to the `scale_[xy]_… functions` to support passing in - 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 #' scales, "top" or "bottom" for horizontal scales
#' @param sec.axis specify a secondary axis #' @param sec.axis specify a secondary axis
#' @export #' @export
scale_x_percent <- function(name = waiver(), breaks = waiver(), scale_x_percent <- function(name = waiver(),
breaks = waiver(),
minor_breaks = waiver(), minor_breaks = waiver(),
limits = NULL, expand = c(0.01,0), oob = censor, guide = waiver(),
na.value = NA_real_, trans = "identity", n.breaks = NULL,
position = "bottom", sec.axis = waiver(), labels, labels,
accuracy = 1, scale = 100, prefix = "", suffix = "%", limits = NULL,
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 = 100,
prefix = "",
suffix = "%",
big.mark = " ",
decimal.mark = ".",
trim = TRUE, ...) {
if (missing(labels)) { if (missing(labels)) {
scales::percent_format( scales::percent_format(
@ -69,12 +82,13 @@ scale_x_percent <- function(name = waiver(), breaks = waiver(),
ggplot2::continuous_scale( ggplot2::continuous_scale(
aesthetics = c( aesthetics = c(
"x", "xmin", "xmax", "xend", "xintercept", "xmin_final", "x", "xmin", "xmax", "xend", "xintercept", "xmin_final",
"xmax_final", "xlower", "xmiddle", "xupper" "xmax_final", "xlower", "xmiddle", "xupper", "x0"
), ),
scale_name = "position_c", scale_name = "position_c",
palette = identity, palette = identity,
name = name, name = name,
breaks = breaks, breaks = breaks,
n.breaks = n.breaks,
minor_breaks = minor_breaks, minor_breaks = minor_breaks,
labels = labels, labels = labels,
limits = limits, limits = limits,
@ -82,7 +96,7 @@ scale_x_percent <- function(name = waiver(), breaks = waiver(),
oob = oob, oob = oob,
na.value = na.value, na.value = na.value,
trans = trans, trans = trans,
guide = "none", guide = guide,
position = position, position = position,
super = ScaleContinuousPosition super = ScaleContinuousPosition
) -> sc ) -> sc
@ -102,13 +116,26 @@ scale_x_percent <- function(name = waiver(), breaks = waiver(),
#' @rdname scale_x_percent #' @rdname scale_x_percent
#' @export #' @export
scale_y_percent <- function(name = waiver(), breaks = waiver(), scale_y_percent <- function(name = waiver(),
breaks = waiver(),
minor_breaks = waiver(), minor_breaks = waiver(),
limits = NULL, expand = c(0.01,0), oob = censor, guide = waiver(),
na.value = NA_real_, trans = "identity", n.breaks = NULL,
position = "left", sec.axis = waiver(), labels, labels,
accuracy = 1, scale = 100, prefix = "", suffix = "%", limits = NULL,
big.mark = " ", decimal.mark = ".", trim = TRUE, ...) { 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)) { if (missing(labels)) {
scales::percent_format( scales::percent_format(
@ -132,6 +159,7 @@ scale_y_percent <- function(name = waiver(), breaks = waiver(),
palette = identity, palette = identity,
name = name, name = name,
breaks = breaks, breaks = breaks,
n.breaks = n.breaks,
minor_breaks = minor_breaks, minor_breaks = minor_breaks,
labels = labels, labels = labels,
limits = limits, limits = limits,
@ -139,7 +167,7 @@ scale_y_percent <- function(name = waiver(), breaks = waiver(),
oob = oob, oob = oob,
na.value = na.value, na.value = na.value,
trans = trans, trans = trans,
guide = "none", guide = guide,
position = position, position = position,
super = ScaleContinuousPosition super = ScaleContinuousPosition
) -> sc ) -> sc
@ -162,14 +190,26 @@ scale_y_percent <- function(name = waiver(), breaks = waiver(),
#' [scales::comma_format()] or [scales::percent_format()] #' [scales::comma_format()] or [scales::percent_format()]
#' @param ... passed on to [scales::comma_format()] or [scales::percent_format()] #' @param ... passed on to [scales::comma_format()] or [scales::percent_format()]
#' @export #' @export
scale_x_comma <- function(name = waiver(), breaks = waiver(), scale_x_comma <- function(name = waiver(),
breaks = waiver(),
minor_breaks = waiver(), minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL, limits = NULL,
expand = c(0.01,0), oob = censor, expand = c(0.01,0),
na.value = NA_real_, trans = "identity", oob = censor,
position = "bottom", sec.axis = waiver(), labels, na.value = NA_real_,
accuracy = 1, scale = 1, prefix = "", suffix = "", trans = "identity",
big.mark = ",", decimal.mark = ".", trim = TRUE, position = "bottom",
sec.axis = waiver(),
accuracy = 1,
scale = 1,
prefix = "",
suffix = "",
big.mark = ",",
decimal.mark = ".",
trim = TRUE,
...) { ...) {
if (missing(labels)) { if (missing(labels)) {
@ -195,6 +235,7 @@ scale_x_comma <- function(name = waiver(), breaks = waiver(),
palette = identity, palette = identity,
name = name, name = name,
breaks = breaks, breaks = breaks,
n.breaks = n.breaks,
minor_breaks = minor_breaks, minor_breaks = minor_breaks,
labels = labels, labels = labels,
limits = limits, limits = limits,
@ -202,7 +243,7 @@ scale_x_comma <- function(name = waiver(), breaks = waiver(),
oob = oob, oob = oob,
na.value = na.value, na.value = na.value,
trans = trans, trans = trans,
guide = "none", guide = guide,
position = position, position = position,
super = ScaleContinuousPosition super = ScaleContinuousPosition
) -> sc ) -> sc
@ -225,11 +266,23 @@ scale_x_comma <- function(name = waiver(), breaks = waiver(),
scale_y_comma <- function(name = waiver(), scale_y_comma <- function(name = waiver(),
breaks = waiver(), breaks = waiver(),
minor_breaks = waiver(), minor_breaks = waiver(),
limits = NULL, expand = c(0.01,0), oob = censor, guide = waiver(),
na.value = NA_real_, trans = "identity", n.breaks = NULL,
position = "left", sec.axis = waiver(), labels, labels,
accuracy = 1, scale = 1, prefix = "", suffix = "", limits = NULL,
big.mark = ",", decimal.mark = ".", trim = TRUE, 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)) { if (missing(labels)) {
@ -255,6 +308,7 @@ scale_y_comma <- function(name = waiver(),
palette = identity, palette = identity,
name = name, name = name,
breaks = breaks, breaks = breaks,
n.breaks = n.breaks,
minor_breaks = minor_breaks, minor_breaks = minor_breaks,
labels = labels, labels = labels,
limits = limits, limits = limits,
@ -262,7 +316,7 @@ scale_y_comma <- function(name = waiver(),
oob = oob, oob = oob,
na.value = na.value, na.value = na.value,
trans = trans, trans = trans,
guide = "none", guide = guide,
position = position, position = position,
super = ScaleContinuousPosition super = ScaleContinuousPosition
) -> sc ) -> 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 A covenience function intended for basic, fixed-scale plots only (i.e. does not handle
free scales in facets).\cr free scales in facets).\cr
\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 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 it) so if the plt takes a while (i.e. has lots of data or transforms) this will also
take a while. take a while.

12
man/scale_ft.Rd

@ -16,11 +16,12 @@ scale_fill_ft(...)
\item{...}{ \item{...}{
Arguments passed on to \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale}} Arguments passed on to \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale}}
\describe{ \describe{
\item{\code{aesthetics}}{The names of the aesthetics that this scale works with} \item{\code{aesthetics}}{The names of the aesthetics that this scale works with.}
\item{\code{scale_name}}{The name of the scale} \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 \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.} 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 \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
@ -28,8 +29,7 @@ omitted.}
\item{\code{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 \item \code{waiver()} for the default breaks (the scale limits)
transformation object
\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
@ -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; 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{\code{guide}}{A function used to create a guide or its name. See \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} \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{...}{ \item{...}{
Arguments passed on to \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale}} Arguments passed on to \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale}}
\describe{ \describe{
\item{\code{aesthetics}}{The names of the aesthetics that this scale works with} \item{\code{aesthetics}}{The names of the aesthetics that this scale works with.}
\item{\code{scale_name}}{The name of the scale} \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 \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.} 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 \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
@ -28,8 +29,7 @@ omitted.}
\item{\code{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 \item \code{waiver()} for the default breaks (the scale limits)
transformation object
\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
@ -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; 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{\code{guide}}{A function used to create a guide or its name. See \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} \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(), name = waiver(),
breaks = waiver(), breaks = waiver(),
minor_breaks = waiver(), minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL, limits = NULL,
expand = c(0.01, 0), expand = c(0.01, 0),
oob = censor, oob = censor,
@ -18,7 +21,6 @@ scale_x_percent(
trans = "identity", trans = "identity",
position = "bottom", position = "bottom",
sec.axis = waiver(), sec.axis = waiver(),
labels,
accuracy = 1, accuracy = 1,
scale = 100, scale = 100,
prefix = "", prefix = "",
@ -33,6 +35,9 @@ scale_y_percent(
name = waiver(), name = waiver(),
breaks = waiver(), breaks = waiver(),
minor_breaks = waiver(), minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL, limits = NULL,
expand = c(0.01, 0), expand = c(0.01, 0),
oob = censor, oob = censor,
@ -40,7 +45,6 @@ scale_y_percent(
trans = "identity", trans = "identity",
position = "left", position = "left",
sec.axis = waiver(), sec.axis = waiver(),
labels,
accuracy = 1, accuracy = 1,
scale = 100, scale = 100,
prefix = "", prefix = "",
@ -55,6 +59,9 @@ scale_x_comma(
name = waiver(), name = waiver(),
breaks = waiver(), breaks = waiver(),
minor_breaks = waiver(), minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL, limits = NULL,
expand = c(0.01, 0), expand = c(0.01, 0),
oob = censor, oob = censor,
@ -62,7 +69,6 @@ scale_x_comma(
trans = "identity", trans = "identity",
position = "bottom", position = "bottom",
sec.axis = waiver(), sec.axis = waiver(),
labels,
accuracy = 1, accuracy = 1,
scale = 1, scale = 1,
prefix = "", prefix = "",
@ -77,6 +83,9 @@ scale_y_comma(
name = waiver(), name = waiver(),
breaks = waiver(), breaks = waiver(),
minor_breaks = waiver(), minor_breaks = waiver(),
guide = waiver(),
n.breaks = NULL,
labels,
limits = NULL, limits = NULL,
expand = c(0.01, 0), expand = c(0.01, 0),
oob = censor, oob = censor,
@ -84,7 +93,6 @@ scale_y_comma(
trans = "identity", trans = "identity",
position = "left", position = "left",
sec.axis = waiver(), sec.axis = waiver(),
labels,
accuracy = 1, accuracy = 1,
scale = 1, scale = 1,
prefix = "", prefix = "",
@ -120,6 +128,9 @@ each major break)
\item A function that given the limits returns a vector of minor breaks. \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. \item{limits}{A numeric vector of length two providing limits of the scale.
Use \code{NA} to refer to the existing minimum or maximum.} 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{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 \item{accuracy, scale, prefix, suffix, big.mark, decimal.mark, trim}{See
[scales::comma_format()] or [scales::percent_format()]} [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() update_geom_font_defaults()
count(mpg, class) %>% count(mpg, class) \%>\%
ggplot(aes(class, n)) + ggplot(aes(class, n)) +
geom_col() + geom_col() +
geom_text(aes(label=n), nudge_y=3) + 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 # note: may need to make this font_es on Windows
update_geom_font_defaults(family=font_es_light) update_geom_font_defaults(family=font_es_light)
count(mpg, class) %>% count(mpg, class) \%>\%
ggplot(aes(class, n)) + ggplot(aes(class, n)) +
geom_col() + geom_col() +
geom_text(aes(label=n), nudge_y=3) + 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 # note: make this font_rc on Windows
update_geom_font_defaults(family=font_rc_light) update_geom_font_defaults(family=font_rc_light)
count(mpg, class) %>% count(mpg, class) \%>\%
ggplot(aes(class, n)) + ggplot(aes(class, n)) +
geom_col() + geom_col() +
geom_text(aes(label=n), nudge_y=3) + 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) update_geom_font_defaults(family=font_pub)
count(mpg, class) %>% count(mpg, class) \%>\%
ggplot(aes(class, n)) + ggplot(aes(class, n)) +
geom_col() + geom_col() +
geom_text(aes(label=n), nudge_y=3) + 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 # note: make this font_rc on Windows
update_geom_font_defaults(family=font_rc_light) update_geom_font_defaults(family=font_rc_light)
count(mpg, class) %>% count(mpg, class) \%>\%
ggplot(aes(class, n)) + ggplot(aes(class, n)) +
geom_col() + geom_col() +
geom_text(aes(label=n), nudge_y=3) + 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 # note: make this font_rc on Windows
update_geom_font_defaults(family=font_rc_light) update_geom_font_defaults(family=font_rc_light)
count(mpg, class) %>% count(mpg, class) \%>\%
ggplot(aes(class, n)) + ggplot(aes(class, n)) +
geom_col() + geom_col() +
geom_text(aes(label=n), nudge_y=3) + geom_text(aes(label=n), nudge_y=3) +

Loading…
Cancel
Save