Skip to content

Commit edda7e4

Browse files
committed
resolve merge conflict
Merge branch 'main' into S7_objects # Conflicts: # R/aes.R # R/layer.R # R/plot-build.R # R/theme.R
2 parents 9acc1ee + 183e7ad commit edda7e4

File tree

167 files changed

+20896
-25086
lines changed

Some content is hidden

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

167 files changed

+20896
-25086
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ Collate:
249249
'stat-bindot.R'
250250
'stat-binhex.R'
251251
'stat-boxplot.R'
252+
'stat-connect.R'
252253
'stat-contour.R'
253254
'stat-count.R'
254255
'stat-density-2d.R'

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ export(StatBin2d)
238238
export(StatBindot)
239239
export(StatBinhex)
240240
export(StatBoxplot)
241+
export(StatConnect)
241242
export(StatContour)
242243
export(StatContourFilled)
243244
export(StatCount)
@@ -670,6 +671,7 @@ export(stat_bin_2d)
670671
export(stat_bin_hex)
671672
export(stat_binhex)
672673
export(stat_boxplot)
674+
export(stat_connect)
673675
export(stat_contour)
674676
export(stat_contour_filled)
675677
export(stat_count)
@@ -727,7 +729,6 @@ export(theme_sub_panel)
727729
export(theme_sub_plot)
728730
export(theme_sub_strip)
729731
export(theme_test)
730-
export(theme_transparent)
731732
export(theme_update)
732733
export(theme_void)
733734
export(transform_position)

NEWS.md

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

3+
* `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)
317
* New parameters for `geom_label()` (@teunbrand and @steveharoz, #5365):
418
* The `linewidth` aesthetic is now applied and replaces the `label.size`
519
argument.
@@ -239,8 +253,8 @@
239253
and (non-text) margins inherit from (@teunbrand, #5622).
240254
* `geom_ribbon()` can have varying `fill` or `alpha` in linear coordinate
241255
systems (@teunbrand, #4690).
242-
* `geom_tile()` computes default widths and heights per panel instead of
243-
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).
244258
* The `fill` of the `panel.border` theme setting is ignored and forced to be
245259
transparent (#5782).
246260
* `stat_align()` skips computation when there is only 1 group and therefore
@@ -270,8 +284,11 @@
270284
is setup once in total instead of once per group (@teunbrand, #5971)
271285
* `facet_grid(space = "free")` can now be combined with `coord_fixed()`
272286
(@teunbrand, #4584).
273-
* `theme_classic()` now has black ticks and text instead of dark gray. In
274-
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.
275292
* {tibble} is now suggested instead of imported (@teunbrand, #5986)
276293
* The ellipsis argument is now checked in `fortify()`, `get_alt_text()`,
277294
`labs()` and several guides (@teunbrand, #3196).
@@ -308,6 +325,21 @@
308325
(@teunbrand, #3669).
309326
* Added `scale_{x/y}_time(date_breaks, date_minor_breaks, date_labels)`
310327
(@teunbrand, #4335).
328+
* (internal) `legend.key.width` and `legend.key.height` calculations are no
329+
longer precomputed before guides are drawn (@teunbrand, #6339)
330+
* `ggsave()` can write a multi-page pdf file when provided with a list of plots
331+
(@teunbrand, #5093).
332+
* (internal) When `validate_subclass()` fails to find a class directly, it tries
333+
to retrieve the class via constructor functions (@teunbrand).
334+
* (internal) The ViewScale class has a `make_fixed_copy()` method to permit
335+
copying trained position scales (#3441).
336+
* `draw_key_rect()` replaces a `NA` fill by the `colour` aesthetic and
337+
`draw_key_polygon()` has 0 linewidth as internal default (@teunbrand, #5385).
338+
* Improved consistency of curve direction in `geom_curve()` (@teunbrand, #5069)
339+
* `linetype = NA` is now interpreted to mean 'no line' instead of raising errors
340+
(@teunbrand, #6269).
341+
* The default colour and fill scales have a new `palette` argument
342+
(@teunbrand, #6064).
311343

312344
# ggplot2 3.5.1
313345

R/aes.R

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ is_position_aes <- function(vars) {
280280
#'
281281
#' @export
282282
aes_ <- function(x, y, ...) {
283-
deprecate_soft0(
283+
deprecate_warn0(
284284
"3.0.0",
285285
"aes_()",
286286
details = "Please use tidy evaluation idioms with `aes()`"
@@ -307,7 +307,7 @@ aes_ <- function(x, y, ...) {
307307
#' @rdname aes_
308308
#' @export
309309
aes_string <- function(x, y, ...) {
310-
deprecate_soft0(
310+
deprecate_warn0(
311311
"3.0.0",
312312
"aes_string()",
313313
details = c(
@@ -348,7 +348,9 @@ aes_all <- function(vars) {
348348

349349
# Quosure the symbols in the empty environment because they can only
350350
# refer to the data mask
351-
class_mapping(lapply(vars, function(x) new_quosure(as.name(x), emptyenv())))
351+
x <- class_mapping(lapply(vars, function(x) new_quosure(as.name(x), emptyenv())))
352+
class(x) <- union("unlabelled", class(x))
353+
x
352354
}
353355

354356
#' Automatic aesthetic mapping
@@ -361,29 +363,7 @@ aes_all <- function(vars) {
361363
#' @keywords internal
362364
#' @export
363365
aes_auto <- function(data = NULL, ...) {
364-
deprecate_warn0("2.0.0", "aes_auto()")
365-
366-
# detect names of data
367-
if (is.null(data)) {
368-
cli::cli_abort("{.fn aes_auto} requires a {.cls data.frame} or names of data.frame.")
369-
} else if (is.data.frame(data)) {
370-
vars <- names(data)
371-
} else {
372-
vars <- data
373-
}
374-
375-
# automatically detected aes
376-
vars <- intersect(ggplot_global$all_aesthetics, vars)
377-
names(vars) <- vars
378-
aes <- lapply(vars, function(x) parse(text = x)[[1]])
379-
380-
# explicitly defined aes
381-
if (length(match.call()) > 2) {
382-
args <- as.list(match.call()[-1])
383-
aes <- c(aes, args[names(args) != "data"])
384-
}
385-
386-
class_mapping(rename_aes(aes))
366+
lifecycle::deprecate_stop("2.0.0", "aes_auto()")
387367
}
388368

389369
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)