Skip to content

Commit 524f139

Browse files
authored
Merge branch 'main' into stack_divide_zero
2 parents c90b6a3 + 428d122 commit 524f139

File tree

138 files changed

+20485
-24837
lines changed

Some content is hidden

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

138 files changed

+20485
-24837
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ Collate:
247247
'stat-bindot.R'
248248
'stat-binhex.R'
249249
'stat-boxplot.R'
250+
'stat-connect.R'
250251
'stat-contour.R'
251252
'stat-count.R'
252253
'stat-density-2d.R'

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ export(StatBin2d)
257257
export(StatBindot)
258258
export(StatBinhex)
259259
export(StatBoxplot)
260+
export(StatConnect)
260261
export(StatContour)
261262
export(StatContourFilled)
262263
export(StatCount)
@@ -684,6 +685,7 @@ export(stat_bin_2d)
684685
export(stat_bin_hex)
685686
export(stat_binhex)
686687
export(stat_boxplot)
688+
export(stat_connect)
687689
export(stat_contour)
688690
export(stat_contour_filled)
689691
export(stat_count)
@@ -741,7 +743,6 @@ export(theme_sub_panel)
741743
export(theme_sub_plot)
742744
export(theme_sub_strip)
743745
export(theme_test)
744-
export(theme_transparent)
745746
export(theme_update)
746747
export(theme_void)
747748
export(transform_position)

NEWS.md

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

33
* `position_fill()` avoids stacking observations of zero (@teunbrand, #6338)
4+
* New `layer(layout)` argument to interact with facets (@teunbrand, #3062)
5+
* New `stat_connect()` to connect points via steps or other shapes
6+
(@teunbrand, #6228)
7+
* Fixed regression with incorrectly drawn gridlines when using `coord_flip()`
8+
(@teunbrand, #6293).
9+
* Deprecated functions and arguments prior to ggplot2 3.0.0 throw errors instead
10+
of warnings.
11+
* Functions and arguments that were soft-deprecated up to ggplot2 3.4.0 now
12+
throw warnings.
13+
* (internal) layer data can be attenuated with parameter attributes
14+
(@teunbrand, #3175).
15+
* Date scales silently coerce <POSIXct> to <Date> and datetime scales silently
16+
coerce <Date> to <POSIXct> (@laurabrianna, #3533)
417
* New parameters for `geom_label()` (@teunbrand and @steveharoz, #5365):
518
* The `linewidth` aesthetic is now applied and replaces the `label.size`
619
argument.
@@ -240,8 +253,8 @@
240253
and (non-text) margins inherit from (@teunbrand, #5622).
241254
* `geom_ribbon()` can have varying `fill` or `alpha` in linear coordinate
242255
systems (@teunbrand, #4690).
243-
* `geom_tile()` computes default widths and heights per panel instead of
244-
per layer (@teunbrand, #5740).
256+
* `geom_tile()` and `position_jitter()` computes default widths and heights
257+
per panel instead of per layer (@teunbrand, #5740, #3722).
245258
* The `fill` of the `panel.border` theme setting is ignored and forced to be
246259
transparent (#5782).
247260
* `stat_align()` skips computation when there is only 1 group and therefore
@@ -271,8 +284,11 @@
271284
is setup once in total instead of once per group (@teunbrand, #5971)
272285
* `facet_grid(space = "free")` can now be combined with `coord_fixed()`
273286
(@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).
287+
* `theme_classic()` has the following changes (@teunbrand, #5978 & #6320):
288+
* Axis ticks are now black (`ink`-coloured) instead of dark gray.
289+
* Axis line ends are now `"square"`.
290+
* The panel grid is now blank at the `panel.grid` hierarchy level instead of
291+
the `panel.grid.major` and `panel.grid.minor` levels.
276292
* {tibble} is now suggested instead of imported (@teunbrand, #5986)
277293
* The ellipsis argument is now checked in `fortify()`, `get_alt_text()`,
278294
`labs()` and several guides (@teunbrand, #3196).
@@ -303,10 +319,19 @@
303319
particularly for data-points with a low radius near the center
304320
(@teunbrand, #5023).
305321
* All scales now expose the `aesthetics` parameter (@teunbrand, #5841)
322+
* Staged expressions are handled more gracefully if legends cannot resolve them
323+
(@teunbrand, #6264).
306324
* New `theme(legend.key.justification)` to control the alignment of legend keys
307325
(@teunbrand, #3669).
308326
* Added `scale_{x/y}_time(date_breaks, date_minor_breaks, date_labels)`
309327
(@teunbrand, #4335).
328+
* `ggsave()` can write a multi-page pdf file when provided with a list of plots
329+
(@teunbrand, #5093).
330+
* (internal) When `validate_subclass()` fails to find a class directly, it tries
331+
to retrieve the class via constructor functions (@teunbrand).
332+
* (internal) The ViewScale class has a `make_fixed_copy()` method to permit
333+
copying trained position scales (#3441).
334+
* Improved consistency of curve direction in `geom_curve()` (@teunbrand, #5069)
310335

311336
# ggplot2 3.5.1
312337

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-.R

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,3 +872,95 @@ censor_labels <- function(ranges, layout, labels) {
872872
}
873873
ranges
874874
}
875+
876+
map_facet_data <- function(data, layout, params) {
877+
878+
if (empty(data)) {
879+
return(vec_cbind(data %|W|% NULL, PANEL = integer(0)))
880+
}
881+
882+
vars <- params$facet %||% c(params$rows, params$cols)
883+
884+
if (length(vars) == 0) {
885+
data$PANEL <- layout$PANEL
886+
return(data)
887+
}
888+
889+
grid_layout <- all(c("rows", "cols") %in% names(params))
890+
layer_layout <- attr(data, "layout")
891+
if (identical(layer_layout, "fixed")) {
892+
n <- vec_size(data)
893+
data <- vec_rep(data, vec_size(layout))
894+
data$PANEL <- vec_rep_each(layout$PANEL, n)
895+
return(data)
896+
}
897+
898+
# Compute faceting values
899+
facet_vals <- eval_facets(vars, data, params$.possible_columns)
900+
901+
include_margins <- !isFALSE(params$margin %||% FALSE) &&
902+
nrow(facet_vals) == nrow(data) && grid_layout
903+
if (include_margins) {
904+
# Margins are computed on evaluated faceting values (#1864).
905+
facet_vals <- reshape_add_margins(
906+
vec_cbind(facet_vals, .index = seq_len(nrow(facet_vals))),
907+
list(intersect(names(params$rows), names(facet_vals)),
908+
intersect(names(params$cols), names(facet_vals))),
909+
params$margins %||% FALSE
910+
)
911+
# Apply recycling on original data to fit margins
912+
# We're using base subsetting here because `data` might have a superclass
913+
# that isn't handled well by vctrs::vec_slice
914+
data <- data[facet_vals$.index, , drop = FALSE]
915+
facet_vals$.index <- NULL
916+
}
917+
918+
# If we need to fix rows or columns, we make the corresponding faceting
919+
# variables missing on purpose
920+
if (grid_layout) {
921+
if (identical(layer_layout, "fixed_rows")) {
922+
facet_vals <- facet_vals[setdiff(names(facet_vals), names(params$cols))]
923+
}
924+
if (identical(layer_layout, "fixed_cols")) {
925+
facet_vals <- facet_vals[setdiff(names(facet_vals), names(params$rows))]
926+
}
927+
}
928+
929+
# If any faceting variables are missing, add them in by
930+
# duplicating the data
931+
missing_facets <- setdiff(names(vars), names(facet_vals))
932+
if (length(missing_facets) > 0) {
933+
934+
to_add <- unique0(layout[missing_facets])
935+
936+
data_rep <- rep.int(seq_len(nrow(data)), nrow(to_add))
937+
facet_rep <- rep(seq_len(nrow(to_add)), each = nrow(data))
938+
939+
data <- unrowname(data[data_rep, , drop = FALSE])
940+
facet_vals <- unrowname(vec_cbind(
941+
unrowname(facet_vals[data_rep, , drop = FALSE]),
942+
unrowname(to_add[facet_rep, , drop = FALSE])
943+
))
944+
}
945+
946+
if (nrow(facet_vals) < 1) {
947+
# Add PANEL variable
948+
data$PANEL <- NO_PANEL
949+
return(data)
950+
}
951+
952+
facet_vals[] <- lapply(facet_vals, as_unordered_factor)
953+
facet_vals[] <- lapply(facet_vals, addNA, ifany = TRUE)
954+
layout[] <- lapply(layout, as_unordered_factor)
955+
956+
# Add PANEL variable
957+
keys <- join_keys(facet_vals, layout, by = names(vars))
958+
data$PANEL <- layout$PANEL[match(keys$x, keys$y)]
959+
960+
# Filter panels when layer_layout is an integer
961+
if (is_integerish(layer_layout)) {
962+
data <- vec_slice(data, data$PANEL %in% layer_layout)
963+
}
964+
965+
data
966+
}

0 commit comments

Comments
 (0)