Skip to content

Commit ae867aa

Browse files
authored
Merge branch 'main' into flexible_palettes
2 parents 937d306 + 4eaa98b commit ae867aa

File tree

151 files changed

+20618
-24868
lines changed

Some content is hidden

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

151 files changed

+20618
-24868
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Imports:
3535
cli,
3636
grDevices,
3737
grid,
38-
gtable (>= 0.1.1),
38+
gtable (>= 0.3.6),
3939
isoband,
4040
lifecycle (> 1.0.1),
4141
rlang (>= 1.1.0),
@@ -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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ S3method("[[",ggproto)
1313
S3method("[[<-",uneval)
1414
S3method(.DollarNames,ggproto)
1515
S3method(as.data.frame,mapped_discrete)
16+
S3method(as.gtable,ggplot)
17+
S3method(as.gtable,ggplot_built)
1618
S3method(as.list,ggproto)
1719
S3method(autolayer,default)
1820
S3method(autoplot,default)
@@ -257,6 +259,7 @@ export(StatBin2d)
257259
export(StatBindot)
258260
export(StatBinhex)
259261
export(StatBoxplot)
262+
export(StatConnect)
260263
export(StatContour)
261264
export(StatContourFilled)
262265
export(StatCount)
@@ -684,6 +687,7 @@ export(stat_bin_2d)
684687
export(stat_bin_hex)
685688
export(stat_binhex)
686689
export(stat_boxplot)
690+
export(stat_connect)
687691
export(stat_contour)
688692
export(stat_contour_filled)
689693
export(stat_count)
@@ -741,7 +745,6 @@ export(theme_sub_panel)
741745
export(theme_sub_plot)
742746
export(theme_sub_strip)
743747
export(theme_test)
744-
export(theme_transparent)
745748
export(theme_update)
746749
export(theme_void)
747750
export(transform_position)

NEWS.md

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

3-
* The default colour and fill scales have a new `palette` argument
4-
(@teunbrand, #6064).
3+
* New `layer(layout)` argument to interact with facets (@teunbrand, #3062)
4+
* New `stat_connect()` to connect points via steps or other shapes
5+
(@teunbrand, #6228)
6+
* Fixed regression with incorrectly drawn gridlines when using `coord_flip()`
7+
(@teunbrand, #6293).
8+
* Deprecated functions and arguments prior to ggplot2 3.0.0 throw errors instead
9+
of warnings.
10+
* Functions and arguments that were soft-deprecated up to ggplot2 3.4.0 now
11+
throw warnings.
12+
* (internal) layer data can be attenuated with parameter attributes
13+
(@teunbrand, #3175).
14+
* Date scales silently coerce <POSIXct> to <Date> and datetime scales silently
15+
coerce <Date> to <POSIXct> (@laurabrianna, #3533)
516
* New parameters for `geom_label()` (@teunbrand and @steveharoz, #5365):
617
* The `linewidth` aesthetic is now applied and replaces the `label.size`
718
argument.
@@ -241,8 +252,8 @@
241252
and (non-text) margins inherit from (@teunbrand, #5622).
242253
* `geom_ribbon()` can have varying `fill` or `alpha` in linear coordinate
243254
systems (@teunbrand, #4690).
244-
* `geom_tile()` computes default widths and heights per panel instead of
245-
per layer (@teunbrand, #5740).
255+
* `geom_tile()` and `position_jitter()` computes default widths and heights
256+
per panel instead of per layer (@teunbrand, #5740, #3722).
246257
* The `fill` of the `panel.border` theme setting is ignored and forced to be
247258
transparent (#5782).
248259
* `stat_align()` skips computation when there is only 1 group and therefore
@@ -272,8 +283,11 @@
272283
is setup once in total instead of once per group (@teunbrand, #5971)
273284
* `facet_grid(space = "free")` can now be combined with `coord_fixed()`
274285
(@teunbrand, #4584).
275-
* `theme_classic()` now has black ticks and text instead of dark gray. In
276-
addition, `theme_classic()`'s axis line end is `"square"` (@teunbrand, #5978).
286+
* `theme_classic()` has the following changes (@teunbrand, #5978 & #6320):
287+
* Axis ticks are now black (`ink`-coloured) instead of dark gray.
288+
* Axis line ends are now `"square"`.
289+
* The panel grid is now blank at the `panel.grid` hierarchy level instead of
290+
the `panel.grid.major` and `panel.grid.minor` levels.
277291
* {tibble} is now suggested instead of imported (@teunbrand, #5986)
278292
* The ellipsis argument is now checked in `fortify()`, `get_alt_text()`,
279293
`labs()` and several guides (@teunbrand, #3196).
@@ -310,6 +324,17 @@
310324
(@teunbrand, #3669).
311325
* Added `scale_{x/y}_time(date_breaks, date_minor_breaks, date_labels)`
312326
(@teunbrand, #4335).
327+
* `ggsave()` can write a multi-page pdf file when provided with a list of plots
328+
(@teunbrand, #5093).
329+
* (internal) When `validate_subclass()` fails to find a class directly, it tries
330+
to retrieve the class via constructor functions (@teunbrand).
331+
* (internal) The ViewScale class has a `make_fixed_copy()` method to permit
332+
copying trained position scales (#3441).
333+
* Improved consistency of curve direction in `geom_curve()` (@teunbrand, #5069)
334+
* `linetype = NA` is now interpreted to mean 'no line' instead of raising errors
335+
(@teunbrand, #6269).
336+
* The default colour and fill scales have a new `palette` argument
337+
(@teunbrand, #6064).
313338

314339
# ggplot2 3.5.1
315340

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)