Skip to content

Commit 507ba57

Browse files
Merge remote-tracking branch 'upstream/main' into fix/issue-3959-guide-axis-other-coords
2 parents 16dc109 + 7484bd7 commit 507ba57

File tree

125 files changed

+1114
-692
lines changed

Some content is hidden

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

125 files changed

+1114
-692
lines changed

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Imports:
4343
scales (>= 1.2.0),
4444
stats,
4545
tibble,
46+
vctrs (>= 0.4.1),
4647
withr (>= 2.0.0)
4748
Suggests:
4849
covr,
@@ -79,7 +80,7 @@ Config/testthat/edition: 3
7980
Encoding: UTF-8
8081
LazyData: true
8182
Roxygen: list(markdown = TRUE)
82-
RoxygenNote: 7.2.0
83+
RoxygenNote: 7.2.0.9000
8384
Collate:
8485
'ggproto.r'
8586
'ggplot-global.R'
@@ -230,6 +231,7 @@ Collate:
230231
'scale-view.r'
231232
'scale-viridis.r'
232233
'scales-.r'
234+
'stat-align.R'
233235
'stat-bin.r'
234236
'stat-bin2d.r'
235237
'stat-bindot.r'

NAMESPACE

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ S3method("$",ggproto)
44
S3method("$",ggproto_parent)
55
S3method("$<-",uneval)
66
S3method("+",gg)
7-
S3method("[",mapped_discrete)
87
S3method("[",uneval)
9-
S3method("[<-",mapped_discrete)
108
S3method("[<-",uneval)
119
S3method("[[",ggproto)
1210
S3method("[[<-",uneval)
1311
S3method(.DollarNames,ggproto)
14-
S3method(as.data.frame,mapped_discrete)
1512
S3method(as.list,ggproto)
1613
S3method(autolayer,default)
1714
S3method(autoplot,default)
18-
S3method(c,mapped_discrete)
1915
S3method(drawDetails,zeroGrob)
2016
S3method(element_grob,element_blank)
2117
S3method(element_grob,element_line)
2218
S3method(element_grob,element_rect)
2319
S3method(element_grob,element_text)
20+
S3method(format,ggplot2_mapped_discrete)
2421
S3method(format,ggproto)
2522
S3method(format,ggproto_method)
2623
S3method(fortify,"NULL")
@@ -142,6 +139,30 @@ S3method(scale_type,sfc)
142139
S3method(single_value,default)
143140
S3method(single_value,factor)
144141
S3method(summary,ggplot)
142+
S3method(vec_arith,ggplot2_mapped_discrete)
143+
S3method(vec_arith.ggplot2_mapped_discrete,MISSING)
144+
S3method(vec_arith.ggplot2_mapped_discrete,default)
145+
S3method(vec_arith.ggplot2_mapped_discrete,ggplot2_mapped_discrete)
146+
S3method(vec_arith.ggplot2_mapped_discrete,numeric)
147+
S3method(vec_arith.numeric,ggplot2_mapped_discrete)
148+
S3method(vec_cast,character.ggplot2_mapped_discrete)
149+
S3method(vec_cast,double.ggplot2_mapped_discrete)
150+
S3method(vec_cast,factor.ggplot2_mapped_discrete)
151+
S3method(vec_cast,ggplot2_mapped_discrete.double)
152+
S3method(vec_cast,ggplot2_mapped_discrete.factor)
153+
S3method(vec_cast,ggplot2_mapped_discrete.ggplot2_mapped_discrete)
154+
S3method(vec_cast,ggplot2_mapped_discrete.integer)
155+
S3method(vec_cast,integer.ggplot2_mapped_discrete)
156+
S3method(vec_math,ggplot2_mapped_discrete)
157+
S3method(vec_ptype2,character.ggplot2_mapped_discrete)
158+
S3method(vec_ptype2,double.ggplot2_mapped_discrete)
159+
S3method(vec_ptype2,factor.ggplot2_mapped_discrete)
160+
S3method(vec_ptype2,ggplot2_mapped_discrete.character)
161+
S3method(vec_ptype2,ggplot2_mapped_discrete.double)
162+
S3method(vec_ptype2,ggplot2_mapped_discrete.factor)
163+
S3method(vec_ptype2,ggplot2_mapped_discrete.ggplot2_mapped_discrete)
164+
S3method(vec_ptype2,ggplot2_mapped_discrete.integer)
165+
S3method(vec_ptype2,integer.ggplot2_mapped_discrete)
145166
S3method(widthDetails,titleGrob)
146167
S3method(widthDetails,zeroGrob)
147168
export("%+%")
@@ -231,6 +252,7 @@ export(ScaleDiscrete)
231252
export(ScaleDiscreteIdentity)
232253
export(ScaleDiscretePosition)
233254
export(Stat)
255+
export(StatAlign)
234256
export(StatBin)
235257
export(StatBin2d)
236258
export(StatBindot)
@@ -609,6 +631,7 @@ export(should_stop)
609631
export(stage)
610632
export(standardise_aes_names)
611633
export(stat)
634+
export(stat_align)
612635
export(stat_bin)
613636
export(stat_bin2d)
614637
export(stat_bin_2d)
@@ -668,6 +691,7 @@ export(update_geom_defaults)
668691
export(update_labels)
669692
export(update_stat_defaults)
670693
export(vars)
694+
export(vec_arith.ggplot2_mapped_discrete)
671695
export(waiver)
672696
export(wrap_dims)
673697
export(xlab)
@@ -679,6 +703,7 @@ import(grid)
679703
import(gtable)
680704
import(rlang)
681705
import(scales)
706+
import(vctrs)
682707
importFrom(glue,glue)
683708
importFrom(glue,glue_collapse)
684709
importFrom(lifecycle,deprecated)

NEWS.md

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

3+
* Added `stat_align()` to align data without common x-coordinates prior to
4+
stacking. This is now the default stat for `geom_area()` (@thomasp85, #4850)
5+
6+
* Fix a bug in `stat_contour_filled()` where break value differences below a
7+
certain number of digits would cause the computations to fail (@thomasp85,
8+
#4874)
9+
310
* `stage()` now properly refers to the values without scale transformations for
411
the stage of `after_stat`. If your code requires the scaled version of the
512
values for some reason, you have to apply the same transformation by yourself,

R/aes.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ rename_aes <- function(x) {
179179
names(x) <- standardise_aes_names(names(x))
180180
duplicated_names <- names(x)[duplicated(names(x))]
181181
if (length(duplicated_names) > 0L) {
182-
cli::cli_warn("Duplicated aesthetics after name standardisation: {.field {unique(duplicated_names)}}")
182+
cli::cli_warn("Duplicated aesthetics after name standardisation: {.field {unique0(duplicated_names)}}")
183183
}
184184
x
185185
}

R/annotation-custom.r

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ GeomCustomAnn <- ggproto("GeomCustomAnn", Geom,
7373
if (!inherits(coord, "CoordCartesian")) {
7474
cli::cli_abort("{.fn annotation_custom} only works with {.fn coord_cartesian}")
7575
}
76-
corners <- new_data_frame(list(x = c(xmin, xmax), y = c(ymin, ymax)), n = 2)
76+
corners <- data_frame0(
77+
x = c(xmin, xmax),
78+
y = c(ymin, ymax),
79+
.size = 2
80+
)
7781
data <- coord$transform(corners, panel_params)
7882

7983
x_rng <- range(data$x, na.rm = TRUE)

R/annotation-logticks.r

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
213213
}
214214
}
215215

216-
gTree(children = do.call("gList", ticks))
216+
gTree(children = inject(gList(!!!ticks)))
217217
},
218218

219219
default_aes = aes(colour = "black", size = 0.5, linetype = 1, alpha = 1)
@@ -254,7 +254,12 @@ calc_logticks <- function(base = 10, ticks_per_base = base - 1,
254254
longtick_after_base <- floor(ticks_per_base/2)
255255
tickend[ cycleIdx == longtick_after_base ] <- midend
256256

257-
tickdf <- new_data_frame(list(value = ticks, start = start, end = tickend), n = length(ticks))
257+
tickdf <- data_frame0(
258+
value = ticks,
259+
start = start,
260+
end = tickend,
261+
.size = length(ticks)
262+
)
258263

259264
return(tickdf)
260265
}

R/annotation-map.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ GeomAnnotationMap <- ggproto("GeomAnnotationMap", GeomMap,
9393
# must be sequential integers
9494
coords <- coord_munch(coord, map, panel_params)
9595
coords$group <- coords$group %||% coords$id
96-
grob_id <- match(coords$group, unique(coords$group))
96+
grob_id <- match(coords$group, unique0(coords$group))
9797

9898
polygonGrob(coords$x, coords$y, default.units = "native",
9999
id = grob_id,

R/annotation-raster.r

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ GeomRasterAnn <- ggproto("GeomRasterAnn", Geom,
7676
if (!inherits(coord, "CoordCartesian")) {
7777
cli::cli_abort("{.fn annotation_raster} only works with {.fn coord_cartesian}")
7878
}
79-
corners <- new_data_frame(list(x = c(xmin, xmax), y = c(ymin, ymax)), n = 2)
79+
corners <- data_frame0(
80+
x = c(xmin, xmax),
81+
y = c(ymin, ymax),
82+
.size = 2
83+
)
8084
data <- coord$transform(corners, panel_params)
8185

8286
x_rng <- range(data$x, na.rm = TRUE)

R/annotation.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ annotate <- function(geom, x = NULL, y = NULL, xmin = NULL, xmax = NULL,
5757

5858
# Check that all aesthetic have compatible lengths
5959
lengths <- vapply(aesthetics, length, integer(1))
60-
n <- unique(lengths)
60+
n <- unique0(lengths)
6161

6262
# if there is more than one unique length, ignore constants
6363
if (length(n) > 1L) {
@@ -71,7 +71,7 @@ annotate <- function(geom, x = NULL, y = NULL, xmin = NULL, xmax = NULL,
7171
cli::cli_abort("Unequal parameter lengths: {details}")
7272
}
7373

74-
data <- new_data_frame(position, n = n)
74+
data <- data_frame0(!!!position, .size = n)
7575
layer(
7676
geom = geom,
7777
params = list(

R/axis-secondary.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
193193
full_range <- self$transform_range(old_range)
194194

195195
# Test for monotonicity
196-
if (length(unique(sign(diff(full_range)))) != 1)
196+
if (length(unique0(sign(diff(full_range)))) != 1)
197197
cli::cli_abort("Transformation for secondary axes must be monotonic")
198198
},
199199

0 commit comments

Comments
 (0)