Skip to content

Commit c18957b

Browse files
authored
Merge branch 'main' into curve_flipping
2 parents 12de161 + 7e67db3 commit c18957b

File tree

120 files changed

+19576
-24722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+19576
-24722
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ export(theme_sub_panel)
741741
export(theme_sub_plot)
742742
export(theme_sub_strip)
743743
export(theme_test)
744-
export(theme_transparent)
745744
export(theme_update)
746745
export(theme_void)
747746
export(transform_position)

NEWS.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# ggplot2 (development version)
22

3-
* Improved consistency of curve direction in `geom_curve()` (@teunbrand, #5069)
3+
* Fixed regression with incorrectly drawn gridlines when using `coord_flip()`
4+
(@teunbrand, #6293).
5+
* Deprecated functions and arguments prior to ggplot2 3.0.0 throw errors instead
6+
of warnings.
7+
* Functions and arguments that were soft-deprecated up to ggplot2 3.4.0 now
8+
throw warnings.
9+
* (internal) layer data can be attenuated with parameter attributes
10+
(@teunbrand, #3175).
11+
* Date scales silently coerce <POSIXct> to <Date> and datetime scales silently
12+
coerce <Date> to <POSIXct> (@laurabrianna, #3533)
413
* New parameters for `geom_label()` (@teunbrand and @steveharoz, #5365):
514
* The `linewidth` aesthetic is now applied and replaces the `label.size`
615
argument.
@@ -240,8 +249,8 @@
240249
and (non-text) margins inherit from (@teunbrand, #5622).
241250
* `geom_ribbon()` can have varying `fill` or `alpha` in linear coordinate
242251
systems (@teunbrand, #4690).
243-
* `geom_tile()` computes default widths and heights per panel instead of
244-
per layer (@teunbrand, #5740).
252+
* `geom_tile()` and `position_jitter()` computes default widths and heights
253+
per panel instead of per layer (@teunbrand, #5740, #3722).
245254
* The `fill` of the `panel.border` theme setting is ignored and forced to be
246255
transparent (#5782).
247256
* `stat_align()` skips computation when there is only 1 group and therefore
@@ -271,8 +280,11 @@
271280
is setup once in total instead of once per group (@teunbrand, #5971)
272281
* `facet_grid(space = "free")` can now be combined with `coord_fixed()`
273282
(@teunbrand, #4584).
274-
* `theme_classic()` now has black ticks and text instead of dark gray. In
275-
addition, `theme_classic()`'s axis line end is `"square"` (@teunbrand, #5978).
283+
* `theme_classic()` has the following changes (@teunbrand, #5978 & #6320):
284+
* Axis ticks are now black (`ink`-coloured) instead of dark gray.
285+
* Axis line ends are now `"square"`.
286+
* The panel grid is now blank at the `panel.grid` hierarchy level instead of
287+
the `panel.grid.major` and `panel.grid.minor` levels.
276288
* {tibble} is now suggested instead of imported (@teunbrand, #5986)
277289
* The ellipsis argument is now checked in `fortify()`, `get_alt_text()`,
278290
`labs()` and several guides (@teunbrand, #3196).
@@ -303,10 +315,19 @@
303315
particularly for data-points with a low radius near the center
304316
(@teunbrand, #5023).
305317
* All scales now expose the `aesthetics` parameter (@teunbrand, #5841)
318+
* Staged expressions are handled more gracefully if legends cannot resolve them
319+
(@teunbrand, #6264).
306320
* New `theme(legend.key.justification)` to control the alignment of legend keys
307321
(@teunbrand, #3669).
308322
* Added `scale_{x/y}_time(date_breaks, date_minor_breaks, date_labels)`
309323
(@teunbrand, #4335).
324+
* `ggsave()` can write a multi-page pdf file when provided with a list of plots
325+
(@teunbrand, #5093).
326+
* (internal) When `validate_subclass()` fails to find a class directly, it tries
327+
to retrieve the class via constructor functions (@teunbrand).
328+
* (internal) The ViewScale class has a `make_fixed_copy()` method to permit
329+
copying trained position scales (#3441).
330+
* Improved consistency of curve direction in `geom_curve()` (@teunbrand, #5069)
310331

311332
# ggplot2 3.5.1
312333

R/aes.R

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ is_position_aes <- function(vars) {
290290
#'
291291
#' @export
292292
aes_ <- function(x, y, ...) {
293-
deprecate_soft0(
293+
deprecate_warn0(
294294
"3.0.0",
295295
"aes_()",
296296
details = "Please use tidy evaluation idioms with `aes()`"
@@ -317,7 +317,7 @@ aes_ <- function(x, y, ...) {
317317
#' @rdname aes_
318318
#' @export
319319
aes_string <- function(x, y, ...) {
320-
deprecate_soft0(
320+
deprecate_warn0(
321321
"3.0.0",
322322
"aes_string()",
323323
details = c(
@@ -360,7 +360,7 @@ aes_all <- function(vars) {
360360
# refer to the data mask
361361
structure(
362362
lapply(vars, function(x) new_quosure(as.name(x), emptyenv())),
363-
class = "uneval"
363+
class = c("unlabelled_uneval", "uneval")
364364
)
365365
}
366366

@@ -374,29 +374,7 @@ aes_all <- function(vars) {
374374
#' @keywords internal
375375
#' @export
376376
aes_auto <- function(data = NULL, ...) {
377-
deprecate_warn0("2.0.0", "aes_auto()")
378-
379-
# detect names of data
380-
if (is.null(data)) {
381-
cli::cli_abort("{.fn aes_auto} requires a {.cls data.frame} or names of data.frame.")
382-
} else if (is.data.frame(data)) {
383-
vars <- names(data)
384-
} else {
385-
vars <- data
386-
}
387-
388-
# automatically detected aes
389-
vars <- intersect(ggplot_global$all_aesthetics, vars)
390-
names(vars) <- vars
391-
aes <- lapply(vars, function(x) parse(text = x)[[1]])
392-
393-
# explicitly defined aes
394-
if (length(match.call()) > 2) {
395-
args <- as.list(match.call()[-1])
396-
aes <- c(aes, args[names(args) != "data"])
397-
}
398-
399-
structure(rename_aes(aes), class = "uneval")
377+
lifecycle::deprecate_stop("2.0.0", "aes_auto()")
400378
}
401379

402380
mapped_aesthetics <- function(x) {

R/annotation-custom.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ GeomCustomAnn <- ggproto("GeomCustomAnn", Geom,
8080
editGrob(grob, vp = vp, name = paste(grob$name, annotation_id()))
8181
},
8282

83-
default_aes = aes_(xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
83+
default_aes = aes(xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
8484
)
8585

8686
annotation_id <- local({

R/annotation-logticks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
229229
},
230230

231231
default_aes = aes(
232-
colour = from_theme(ink),
232+
colour = from_theme(colour %||% ink),
233233
linewidth = from_theme(linewidth),
234234
linetype = from_theme(linetype),
235235
alpha = 1

R/bin.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,24 @@ bin_loc <- function(x, id) {
240240
)
241241
}
242242

243-
fix_bin_params = function(params, fun, version) {
243+
fix_bin_params <- function(params, fun, version) {
244+
245+
if (package_version(version) < "3.0.0") {
246+
deprecate <- lifecycle::deprecate_stop
247+
} else {
248+
deprecate <- deprecate_warn0
249+
}
244250

245251
if (!is.null(params$origin)) {
246252
args <- paste0(fun, c("(origin)", "(boundary)"))
247-
deprecate_warn0(version, args[1], args[2])
248-
params$boudnary <- params$origin
253+
deprecate(version, args[1], args[2])
254+
params$boundary <- params$origin
249255
params$origin <- NULL
250256
}
251257

252258
if (!is.null(params$right)) {
253259
args <- paste0(fun, c("(right)", "(closed)"))
254-
deprecate_warn0(version, args[1], args[2])
260+
deprecate(version, args[1], args[2])
255261
params$closed <- if (isTRUE(params$right)) "right" else "left"
256262
params$right <- NULL
257263
}

R/facet-grid-.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ facet_grid <- function(rows = NULL, cols = NULL, scales = "fixed",
132132
switch = NULL, drop = TRUE, margins = FALSE,
133133
axes = "margins", axis.labels = "all",
134134
facets = deprecated()) {
135-
# `facets` is deprecated and renamed to `rows`
135+
# `facets` is deprecated
136136
if (lifecycle::is_present(facets)) {
137-
deprecate_warn0("2.2.0", "facet_grid(facets)", "facet_grid(rows)")
138-
rows <- facets
137+
lifecycle::deprecate_stop("2.2.0", "facet_grid(facets)", "facet_grid(rows)")
139138
}
140139

141140
# Should become a warning in a future release
@@ -177,7 +176,7 @@ facet_grid <- function(rows = NULL, cols = NULL, scales = "fixed",
177176
facets_list <- grid_as_facets_list(rows, cols)
178177

179178
# Check for deprecated labellers
180-
labeller <- fix_labeller(labeller)
179+
check_labeller(labeller)
181180

182181
ggproto(NULL, FacetGrid,
183182
shrink = shrink,

R/facet-wrap.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,15 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
174174
)
175175

176176
# Check for deprecated labellers
177-
labeller <- fix_labeller(labeller)
177+
check_labeller(labeller)
178178

179179
# Flatten all facets dimensions into a single one
180180
facets <- compact_facets(facets)
181181

182182
if (lifecycle::is_present(switch) && !is.null(switch)) {
183-
deprecate_warn0("2.2.0", "facet_wrap(switch)", "facet_wrap(strip.position)")
184-
strip.position <- if (switch == "x") "bottom" else "left"
183+
lifecycle::deprecate_stop(
184+
"2.2.0", "facet_wrap(switch)", "facet_wrap(strip.position)"
185+
)
185186
}
186187
strip.position <- arg_match0(strip.position, c("top", "bottom", "left", "right"))
187188

R/fortify-map.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,6 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
159159
borders <- function(database = "world", regions = ".", fill = NA,
160160
colour = "grey50", xlim = NULL, ylim = NULL, ...) {
161161
df <- map_data(database, regions, xlim = xlim, ylim = ylim)
162-
geom_polygon(aes_(~long, ~lat, group = ~group), data = df,
162+
geom_polygon(aes(.data$long, .data$lat, group = .data$group), data = df,
163163
fill = fill, colour = colour, ..., inherit.aes = FALSE)
164164
}

R/geom-.R

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ Geom <- ggproto("Geom",
126126
# Take care of subclasses setting the wrong default when inheriting from
127127
# a geom with rename_size = TRUE
128128
if (self$rename_size && is.null(default_aes$linewidth)) {
129-
deprecate_soft0("3.4.0", I("Using the `size` aesthetic in this geom"), I("`linewidth` in the `default_aes` field and elsewhere"))
129+
deprecate_warn0("3.4.0", I("Using the `size` aesthetic in this geom"), I("`linewidth` in the `default_aes` field and elsewhere"))
130130
default_aes$linewidth <- default_aes$size
131131
}
132132

133133
# Fill in missing aesthetics with their defaults
134134
missing_aes <- setdiff(names(default_aes), names(data))
135135
default_aes <- default_aes[missing_aes]
136-
themed_defaults <- eval_from_theme(default_aes, theme)
136+
themed_defaults <- eval_from_theme(default_aes, theme, class(self))
137137
default_aes[names(themed_defaults)] <- themed_defaults
138138

139139
# Mark staged/scaled defaults as modifier (#6135)
@@ -163,10 +163,15 @@ Geom <- ggproto("Geom",
163163
# If any after_scale mappings are detected they will be resolved here
164164
# This order means that they will have access to all default aesthetics
165165
if (length(modifiers) != 0) {
166-
# Set up evaluation environment
167-
modified_aes <- eval_aesthetics(
168-
substitute_aes(modifiers), data,
169-
mask = list(stage = stage_scaled)
166+
modified_aes <- try_fetch(
167+
eval_aesthetics(
168+
substitute_aes(modifiers), data,
169+
mask = list(stage = stage_scaled)
170+
),
171+
error = function(cnd) {
172+
cli::cli_warn("Unable to apply staged modifications.", parent = cnd)
173+
data_frame0()
174+
}
170175
)
171176

172177
# Check that all output are valid data
@@ -177,10 +182,7 @@ Geom <- ggproto("Geom",
177182
)
178183

179184
modified_aes <- cleanup_mismatched_data(modified_aes, nrow(data), "after_scale")
180-
181-
modified_aes <- data_frame0(!!!modified_aes)
182-
183-
data <- data_frame0(!!!defaults(modified_aes, data))
185+
data[names(modified_aes)] <- modified_aes
184186
}
185187

186188
# Override mappings with params
@@ -237,13 +239,33 @@ Geom <- ggproto("Geom",
237239
#' @rdname is_tests
238240
is.geom <- function(x) inherits(x, "Geom")
239241

240-
eval_from_theme <- function(aesthetics, theme) {
242+
eval_from_theme <- function(aesthetics, theme, class = NULL) {
241243
themed <- is_themed_aes(aesthetics)
242244
if (!any(themed)) {
243245
return(aesthetics)
244246
}
245-
settings <- calc_element("geom", theme) %||% .default_geom_element
246-
lapply(aesthetics[themed], eval_tidy, data = settings)
247+
248+
element <- calc_element("geom", theme) %||% .default_geom_element
249+
class <- setdiff(class, c("Geom", "ggproto", "gg"))
250+
251+
if (length(class) > 0) {
252+
253+
# CamelCase to dot.case
254+
class <- gsub("([A-Za-z])([A-Z])([a-z])", "\\1.\\2\\3", class)
255+
class <- gsub("([a-z])([A-Z])", "\\1.\\2", class)
256+
class <- to_lower_ascii(class)
257+
258+
class <- class[class %in% names(theme)]
259+
260+
# Inherit up to parent geom class
261+
if (length(class) > 0) {
262+
for (cls in rev(class)) {
263+
element <- combine_elements(theme[[cls]], element)
264+
}
265+
}
266+
}
267+
268+
lapply(aesthetics[themed], eval_tidy, data = element)
247269
}
248270

249271
#' Graphical units
@@ -279,7 +301,7 @@ check_aesthetics <- function(x, n) {
279301

280302
fix_linewidth <- function(data, name) {
281303
if (is.null(data$linewidth) && !is.null(data$size)) {
282-
deprecate_soft0("3.4.0", I(paste0("Using the `size` aesthetic with ", name)), I("the `linewidth` aesthetic"))
304+
deprecate_warn0("3.4.0", I(paste0("Using the `size` aesthetic with ", name)), I("the `linewidth` aesthetic"))
283305
data$linewidth <- data$size
284306
}
285307
data

0 commit comments

Comments
 (0)