Skip to content

Release 3.5.2 #6403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ggplot2
Version: 3.5.2.9000
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
Version: 3.5.1.9000
Authors@R: c(
person("Hadley", "Wickham", , "hadley@posit.co", role = "aut",
comment = c(ORCID = "0000-0003-4757-117X")),
Expand Down
27 changes: 15 additions & 12 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ export(element_geom)
export(element_grob)
export(element_line)
export(element_point)
export(element_polygon)
export(element_rect)
export(element_render)
export(element_text)
Expand Down Expand Up @@ -470,22 +469,26 @@ export(guide_transform)
export(guides)
export(has_flipped_aes)
export(is.Coord)
export(is.coord)
export(is.facet)
export(is.geom)
export(is.ggplot)
export(is.ggproto)
export(is.guide)
export(is.guides)
export(is.layer)
export(is.mapping)
export(is.margin)
export(is.position)
export(is.scale)
export(is.stat)
export(is.theme)
export(is.theme_element)
export(is.waiver)
export(is_coord)
export(is_facet)
export(is_geom)
export(is_ggplot)
export(is_ggproto)
export(is_guide)
export(is_guides)
export(is_layer)
export(is_mapping)
export(is_margin)
export(is_position)
export(is_scale)
export(is_stat)
export(is_theme)
export(is_theme_element)
export(label_both)
export(label_bquote)
export(label_context)
Expand Down
1,486 changes: 753 additions & 733 deletions NEWS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion R/aes.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ aes <- function(x, y, ...) {

#' @export
#' @rdname is_tests
is.mapping <- function(x) inherits(x, "uneval")
is_mapping <- function(x) inherits(x, "uneval")

# Wrap symbolic objects in quosures but pull out constants out of
# quosures for backward-compatibility
Expand Down
4 changes: 2 additions & 2 deletions R/bin.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ compute_bins <- function(x, scale = NULL, breaks = NULL, binwidth = NULL, bins =
center = NULL, boundary = NULL,
closed = c("right", "left")) {

range <- if (is.scale(scale)) scale$dimension() else range(x)
range <- if (is_scale(scale)) scale$dimension() else range(x)
check_length(range, 2L)

if (!is.null(breaks)) {
breaks <- allow_lambda(breaks)
if (is.function(breaks)) {
breaks <- breaks(x)
}
if (is.scale(scale) && !scale$is_discrete()) {
if (is_scale(scale) && !scale$is_discrete()) {
breaks <- scale$transform(breaks)
}
check_numeric(breaks)
Expand Down
7 changes: 3 additions & 4 deletions R/coord-.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,16 @@
}
)


#' @export
#' @rdname is_tests
is.coord <- function(x) inherits(x, "Coord")
is_coord <- function(x) inherits(x, "Coord")

Check warning on line 230 in R/coord-.R

View check run for this annotation

Codecov / codecov/patch

R/coord-.R#L230

Added line #L230 was not covered by tests

#' @export
#' @rdname is_tests
#' @usage is.Coord(x) # Deprecated
is.Coord <- function(x) {
deprecate_soft0("3.5.2", "is.Coord()", "is.coord()")
is.coord(x)
deprecate_soft0("3.5.2", "is.Coord()", "is_coord()")
is_coord(x)

Check warning on line 237 in R/coord-.R

View check run for this annotation

Codecov / codecov/patch

R/coord-.R#L236-L237

Added lines #L236 - L237 were not covered by tests
}

# Renders an axis with the correct orientation or zeroGrob if no axis should be
Expand Down
2 changes: 1 addition & 1 deletion R/coord-cartesian-.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ view_scales_from_scale <- function(scale, coord_limits = NULL, expand = TRUE) {
}

panel_guides_grob <- function(guides, position, theme, labels = NULL) {
if (!is.guides(guides)) {
if (!is_guides(guides)) {
return(zeroGrob())
}
pair <- guides$get_position(position)
Expand Down
24 changes: 16 additions & 8 deletions R/facet-.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#' rendered.
#'
#' Extending facets can range from the simple modifications of current facets,
#' to very laborious rewrites with a lot of [gtable()] manipulation.
#' For some examples of both, please see the extension vignette.
#' to very laborious rewrites with a lot of [`gtable()`][gtable::gtable()]
#' manipulation. For some examples of both, please see the extension vignette.
#'
#' `Facet` subclasses, like other extendible ggproto classes, have a range
#' of methods that can be modified. Some of these are required for all new
Expand Down Expand Up @@ -49,7 +49,7 @@
#'
#' - `setup_panel_params`: modifies the x and y ranges for each panel. This is
#' used to allow the `Facet` to interact with the `panel_params`.
#'
#'
#' - `init_scales`: Given a master scale for x and y, create panel
#' specific scales for each panel defined in the layout. The default is to
#' simply clone the master scale.
Expand Down Expand Up @@ -318,10 +318,6 @@
}
)

#' @export
#' @rdname is_tests
is.facet <- function(x) inherits(x, "Facet")

# Helpers -----------------------------------------------------------------

#' Quote faceting variables
Expand Down Expand Up @@ -383,6 +379,18 @@
quos(...)
}

#' @export
#' @rdname is_tests
is_facet <- function(x) inherits(x, "Facet")

Check warning on line 384 in R/facet-.R

View check run for this annotation

Codecov / codecov/patch

R/facet-.R#L384

Added line #L384 was not covered by tests

#' @export
#' @rdname is_tests
#' @usage is.facet(x) # Deprecated
is.facet <- function(x) {
deprecate_soft0("3.5.2", "is.facet()", "is_facet()")
is_facet(x)

Check warning on line 391 in R/facet-.R

View check run for this annotation

Codecov / codecov/patch

R/facet-.R#L390-L391

Added lines #L390 - L391 were not covered by tests
}

#' Accessing a plot's facet strip labels
#'
#' This functions retrieves labels from facet strips with the labeller applied.
Expand Down Expand Up @@ -493,7 +501,7 @@
}

check_vars <- function(x) {
if (is.mapping(x)) {
if (is_mapping(x)) {
cli::cli_abort("Please use {.fn vars} to supply facet variables.")
}
# Native pipe have higher precedence than + so any type of gg object can be
Expand Down
2 changes: 1 addition & 1 deletion R/fortify.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fortify.default <- function(model, data, ...) {
"or an object coercible by {.fn fortify}, or a valid ",
"{.cls data.frame}-like object coercible by {.fn as.data.frame}"
)
if (is.mapping(model)) {
if (is_mapping(model)) {
msg <- c(
paste0(msg, ", not ", obj_type_friendly(model), "."),
"i" = "Did you accidentally pass {.fn aes} to the {.arg data} argument?"
Expand Down
2 changes: 1 addition & 1 deletion R/geom-.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ Geom <- ggproto("Geom",

#' @export
#' @rdname is_tests
is.geom <- function(x) inherits(x, "Geom")
is_geom <- function(x) inherits(x, "Geom")

eval_from_theme <- function(aesthetics, theme, class = NULL) {
themed <- is_themed_aes(aesthetics)
Expand Down
6 changes: 3 additions & 3 deletions R/geom-defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ update_stat_defaults <- function(stat, new) {
#'
#' # Changed theme
#' get_geom_defaults("point", theme(geom = element_geom(ink = "purple")))
get_geom_defaults <- function(geom, theme = theme_get()) {
get_geom_defaults <- function(geom, theme = get_theme()) {
theme <- theme %||% list(geom = .default_geom_element)

if (is.function(geom)) {
geom <- geom()
}
if (is.layer(geom)) {
if (is_layer(geom)) {
data <- data_frame0(.id = 1L)
data <- geom$compute_geom_2(data = data, theme = theme)
data$.id <- NULL
Expand All @@ -108,7 +108,7 @@ get_geom_defaults <- function(geom, theme = theme_get()) {
if (is.character(geom)) {
geom <- validate_subclass(geom, "Geom")
}
if (is.geom(geom)) {
if (is_geom(geom)) {
out <- geom$use_defaults(data = NULL, theme = theme)
return(out)
}
Expand Down
2 changes: 1 addition & 1 deletion R/geom-label.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ GeomLabel <- ggproto("GeomLabel", Geom,
data <- coord$transform(data, panel_params)
data$vjust <- compute_just(data$vjust, data$y, data$x, data$angle)
data$hjust <- compute_just(data$hjust, data$x, data$y, data$angle)
if (!is.margin("margin")) {
if (!is_margin("margin")) {
label.padding <- rep(label.padding, length.out = 4)
}

Expand Down
24 changes: 16 additions & 8 deletions R/ggproto.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Create a new ggproto object
#'
#' Construct a new object with `ggproto()`, test with `is.ggproto()`,
#' Construct a new object with `ggproto()`, test with `is_ggproto()`,
#' and access parent methods/fields with `ggproto_parent()`.
#'
#' ggproto implements a protype based OO system which blurs the lines between
Expand Down Expand Up @@ -52,7 +52,7 @@
#' self$x
#' }
#' )
#' is.ggproto(Adder)
#' is_ggproto(Adder)
#'
#' Adder$add(10)
#' Adder$add(10)
Expand Down Expand Up @@ -88,7 +88,7 @@

super <- find_super()
if (!is.null(super)) {
check_object(super, is.ggproto, "a {.cls ggproto} object", arg = "_inherit")
check_object(super, is_ggproto, "a {.cls ggproto} object", arg = "_inherit")
e$super <- find_super
class(e) <- c(`_class`, class(super))
} else {
Expand All @@ -98,17 +98,25 @@
e
}

#' @export
#' @rdname is_tests
is.ggproto <- function(x) inherits(x, "ggproto")

#' @export
#' @rdname ggproto
#' @param parent,self Access parent class `parent` of object `self`.
ggproto_parent <- function(parent, self) {
structure(list(parent = parent, self = self), class = "ggproto_parent")
}

#' @export
#' @rdname is_tests
is_ggproto <- function(x) inherits(x, "ggproto")

#' @export
#' @rdname is_tests
#' @usage is.ggproto(x) # Deprecated
is.ggproto <- function(x) {
deprecate_soft0("3.5.2", "is.ggproto()", "is_ggproto()")
is_ggproto(x)

Check warning on line 117 in R/ggproto.R

View check run for this annotation

Codecov / codecov/patch

R/ggproto.R#L116-L117

Added lines #L116 - L117 were not covered by tests
}

fetch_ggproto <- function(x, name) {
res <- NULL

Expand Down Expand Up @@ -303,7 +311,7 @@
values <- vapply(obj_names, function(name) {
obj <- x[[name]]
if (is.function(obj)) "function"
else if (is.ggproto(obj)) format(obj, flat = flat)
else if (is_ggproto(obj)) format(obj, flat = flat)

Check warning on line 314 in R/ggproto.R

View check run for this annotation

Codecov / codecov/patch

R/ggproto.R#L314

Added line #L314 was not covered by tests
else if (is.environment(obj)) "environment"
else if (is.null(obj)) "NULL"
else if (is.atomic(obj)) trim(paste(as.character(obj), collapse = " "))
Expand Down
8 changes: 4 additions & 4 deletions R/guide-.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ new_guide <- function(..., available_aes = "any", super) {

# Validate theme settings
if (!is.null(params$theme)) {
check_object(params$theme, is.theme, what = "a {.cls theme} object")
check_object(params$theme, is_theme, what = "a {.cls theme} object")
check_theme(params$theme, call = caller_env())
params$direction <- params$direction %||% params$theme$legend.direction
}
Expand All @@ -68,7 +68,7 @@ new_guide <- function(..., available_aes = "any", super) {

#' @export
#' @rdname is_tests
is.guide <- function(x) inherits(x, "Guide")
is_guide <- function(x) inherits(x, "Guide")

#' @section Guides:
#'
Expand Down Expand Up @@ -376,10 +376,10 @@ Guide <- ggproto(
# Renders tickmarks
build_ticks = function(key, elements, params, position = params$position,
length = elements$ticks_length) {
if (!is.theme_element(elements)) {
if (!is_theme_element(elements)) {
elements <- elements$ticks
}
if (!inherits(elements, "element_line")) {
if (!is_theme_element(elements, "line")) {
return(zeroGrob())
}

Expand Down
4 changes: 2 additions & 2 deletions R/guide-axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ GuideAxis <- ggproto(
override_elements = function(params, elements, theme) {
elements$text <-
label_angle_heuristic(elements$text, params$position, params$angle)
if (inherits(elements$ticks, "element_blank")) {
if (is_theme_element(elements$ticks, "blank")) {
elements$major_length <- unit(0, "cm")
}
if (inherits(elements$minor, "element_blank") || isFALSE(params$minor.ticks)) {
if (is_theme_element(elements$minor, "blank") || isFALSE(params$minor.ticks)) {
elements$minor_length <- unit(0, "cm")
}
return(elements)
Expand Down
2 changes: 0 additions & 2 deletions R/guide-colorbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ NULL
#'
#' Colour bar guide shows continuous colour scales mapped onto values.
#' Colour bar is available with `scale_fill` and `scale_colour`.
#' For more information, see the inspiration for this function:
#' \href{http://www.mathworks.com/help/techdoc/ref/colorbar.html}{Matlab's colorbar function}.
#'
#' Guides can be specified in each `scale_*` or in [guides()].
#' `guide="legend"` in `scale_*` is syntactic sugar for
Expand Down
2 changes: 1 addition & 1 deletion R/guide-legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@

# Set as theme
theme <- compact(theme)
if (!is.theme(theme)) {
if (!is_theme(theme)) {

Check warning on line 813 in R/guide-legend.R

View check run for this annotation

Codecov / codecov/patch

R/guide-legend.R#L813

Added line #L813 was not covered by tests
theme <- inject(theme(!!!theme))
}
theme
Expand Down
6 changes: 3 additions & 3 deletions R/guides-.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ guides <- function(...) {

#' @export
#' @rdname is_tests
is.guides <- function(x) inherits(x, "Guides")
is_guides <- function(x) inherits(x, "Guides")

# Class -------------------------------------------------------------------

Expand Down Expand Up @@ -140,7 +140,7 @@ Guides <- ggproto(
if (is.null(guides)) {
return(invisible())
}
if (is.guides(guides)) {
if (is_guides(guides)) {
guides <- guides$guides
}
self$guides <- defaults(guides, self$guides)
Expand Down Expand Up @@ -912,7 +912,7 @@ validate_guide <- function(guide) {
guide <- fun()
}
}
if (is.guide(guide)) {
if (is_guide(guide)) {
return(guide)
}
if (inherits(guide, "guide") && is.list(guide)) {
Expand Down
Loading
Loading