Skip to content

Commit f58b6ec

Browse files
committed
resolve merge conflict
Merge branch 'main' into upkeep-2025-04 # Conflicts: # R/geom-histogram.R
2 parents 527613c + 4330f9b commit f58b6ec

File tree

263 files changed

+12295
-6192
lines changed

Some content is hidden

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

263 files changed

+12295
-6192
lines changed

DESCRIPTION

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Imports:
4040
isoband,
4141
lifecycle (> 1.0.1),
4242
rlang (>= 1.1.0),
43-
scales (>= 1.3.0),
43+
scales (>= 1.4.0),
4444
stats,
4545
vctrs (>= 0.6.0),
4646
withr (>= 2.5.0)
@@ -64,6 +64,7 @@ Suggests:
6464
ragg (>= 1.2.6),
6565
RColorBrewer,
6666
rmarkdown,
67+
roxygen2,
6768
rpart,
6869
sf (>= 0.7-3),
6970
svglite (>= 2.1.2),
@@ -94,11 +95,15 @@ Collate:
9495
'compat-plyr.R'
9596
'utilities.R'
9697
'aes.R'
98+
'annotation-borders.R'
9799
'utilities-checks.R'
98100
'legend-draw.R'
99101
'geom-.R'
100102
'annotation-custom.R'
101103
'annotation-logticks.R'
104+
'scale-type.R'
105+
'layer.R'
106+
'make-constructor.R'
102107
'geom-polygon.R'
103108
'geom-map.R'
104109
'annotation-map.R'
@@ -143,6 +148,7 @@ Collate:
143148
'geom-col.R'
144149
'geom-path.R'
145150
'geom-contour.R'
151+
'geom-point.R'
146152
'geom-count.R'
147153
'geom-crossbar.R'
148154
'geom-segment.R'
@@ -161,7 +167,6 @@ Collate:
161167
'geom-jitter.R'
162168
'geom-label.R'
163169
'geom-linerange.R'
164-
'geom-point.R'
165170
'geom-pointrange.R'
166171
'geom-quantile.R'
167172
'geom-rug.R'
@@ -187,7 +192,6 @@ Collate:
187192
'guide-colorbar.R'
188193
'guide-colorsteps.R'
189194
'guide-custom.R'
190-
'layer.R'
191195
'guide-none.R'
192196
'guide-old.R'
193197
'guides-.R'
@@ -237,7 +241,6 @@ Collate:
237241
'scale-shape.R'
238242
'scale-size.R'
239243
'scale-steps.R'
240-
'scale-type.R'
241244
'scale-view.R'
242245
'scale-viridis.R'
243246
'scales-.R'

NAMESPACE

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ S3method(element_grob,element_rect)
2828
S3method(element_grob,element_text)
2929
S3method(format,ggproto)
3030
S3method(format,ggproto_method)
31+
S3method(format,rd_section_aesthetics)
3132
S3method(fortify,"NULL")
3233
S3method(fortify,"function")
3334
S3method(fortify,Line)
@@ -95,6 +96,8 @@ S3method(limits,character)
9596
S3method(limits,factor)
9697
S3method(limits,numeric)
9798
S3method(makeContext,dotstackGrob)
99+
S3method(make_constructor,Geom)
100+
S3method(make_constructor,Stat)
98101
S3method(merge_element,default)
99102
S3method(merge_element,element)
100103
S3method(merge_element,element_blank)
@@ -168,6 +171,7 @@ export(CoordQuickmap)
168171
export(CoordRadial)
169172
export(CoordSf)
170173
export(CoordTrans)
174+
export(CoordTransform)
171175
export(Facet)
172176
export(FacetGrid)
173177
export(FacetNull)
@@ -294,6 +298,7 @@ export(after_scale)
294298
export(after_stat)
295299
export(alpha)
296300
export(annotate)
301+
export(annotation_borders)
297302
export(annotation_custom)
298303
export(annotation_logticks)
299304
export(annotation_map)
@@ -322,6 +327,7 @@ export(coord_quickmap)
322327
export(coord_radial)
323328
export(coord_sf)
324329
export(coord_trans)
330+
export(coord_transform)
325331
export(cut_interval)
326332
export(cut_number)
327333
export(cut_width)
@@ -474,7 +480,6 @@ export(is.facet)
474480
export(is.ggplot)
475481
export(is.ggproto)
476482
export(is.theme)
477-
export(is.waiver)
478483
export(is_coord)
479484
export(is_facet)
480485
export(is_geom)
@@ -490,6 +495,7 @@ export(is_scale)
490495
export(is_stat)
491496
export(is_theme)
492497
export(is_theme_element)
498+
export(is_waiver)
493499
export(label_both)
494500
export(label_bquote)
495501
export(label_context)
@@ -505,6 +511,7 @@ export(layer_grob)
505511
export(layer_scales)
506512
export(layer_sf)
507513
export(lims)
514+
export(make_constructor)
508515
export(map_data)
509516
export(margin)
510517
export(margin_auto)

NEWS.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# ggplot2 (development version)
22

3+
* New roxygen tag `@aesthetics` that takes a Geom, Stat or Position class and
4+
generates an 'Aesthetics' section.
5+
* `annotation_borders()` replaces the now-deprecated `borders()`
6+
(@teunbrand, #6392)
7+
* New `make_constructor()` function that builds a standard constructor for
8+
Geom and Stat classes (@teunbrand, #6142).
9+
* In continuous scales, when `breaks` is a function and `n.breaks` is set, the
10+
`n.breaks` will be passed to the `breaks` function. Previously, `n.breaks`
11+
only applied to the default break calculation (@teunbrand, #5972)
12+
* (internal) New `Facet$draw_panel_content()` method for delegating panel
13+
assembly (@Yunuuuu, #6406).
314
* Facet gains a new method `setup_panel_params` to interact with the
415
panel_params setted by Coord object (@Yunuuuu, #6397, #6380)
516
* `position_fill()` avoids stacking observations of zero (@teunbrand, #6338)
@@ -87,7 +98,7 @@
8798
@yutannihilation's prior work, #3120)
8899
* When discrete breaks have names, they'll be used as labels by default
89100
(@teunbrand, #6147).
90-
* The helper function `is.waiver()` is now exported to help extensions to work
101+
* The helper function `is_waiver()` is now exported to help extensions to work
91102
with `waiver()` objects (@arcresu, #6173).
92103
* Date(time) scales now throw appropriate errors when `date_breaks`,
93104
`date_minor_breaks` or `date_labels` are not strings (@RodDalBen, #5880)
@@ -278,6 +289,7 @@
278289
(@teunbrand, #5938, #4327).
279290
* Fixed bug where empty discrete scales weren't recognised as such
280291
(@teunbrand, #5945).
292+
* `coord_trans()` renamed to `coord_transform()` (@nmercadeb, #5825).
281293
* (internal) The summary function of `stat_summary()` and `stat_summary_bin()`
282294
is setup once in total instead of once per group (@teunbrand, #5971)
283295
* `facet_grid(space = "free")` can now be combined with `coord_fixed()`

R/aes.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ aes_ <- function(x, y, ...) {
302302
caller_env <- parent.frame()
303303

304304
as_quosure_aes <- function(x) {
305-
if (is.formula(x) && length(x) == 2) {
305+
if (is_formula(x) && length(x) == 2) {
306306
as_quosure(x)
307307
} else if (is.null(x) || is.call(x) || is.name(x) || is.atomic(x)) {
308308
new_aesthetic(x, caller_env)

R/annotation-borders.R

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#' Create a layer of map borders
2+
#'
3+
#' This is a quick and dirty way to get map data (from the \pkg{maps} package)
4+
#' onto your plot. This is a good place to start if you need some crude
5+
#' reference lines, but you'll typically want something more sophisticated
6+
#' for communication graphics.
7+
#'
8+
#' @param database map data, see [maps::map()] for details
9+
#' @param regions map region
10+
#' @param fill fill colour
11+
#' @param colour border colour
12+
#' @param xlim,ylim latitudinal and longitudinal ranges for extracting map
13+
#' polygons, see [maps::map()] for details.
14+
#' @inheritDotParams geom_polygon
15+
#' @export
16+
#' @examples
17+
#' if (require("maps")) {
18+
#' data(us.cities)
19+
#' capitals <- subset(us.cities, capital == 2)
20+
#' ggplot(capitals, aes(long, lat)) +
21+
#' annotation_borders("state") +
22+
#' geom_point(aes(size = pop)) +
23+
#' scale_size_area() +
24+
#' coord_quickmap()
25+
#' }
26+
#'
27+
#' if (require("maps")) {
28+
#' # Same map, with some world context
29+
#' ggplot(capitals, aes(long, lat)) +
30+
#' annotation_borders("world", xlim = c(-130, -60), ylim = c(20, 50)) +
31+
#' geom_point(aes(size = pop)) +
32+
#' scale_size_area() +
33+
#' coord_quickmap()
34+
#' }
35+
annotation_borders <- function(database = "world", regions = ".", fill = NA,
36+
colour = "grey50", xlim = NULL, ylim = NULL, ...) {
37+
df <- map_data(database, regions, xlim = xlim, ylim = ylim)
38+
annotate(
39+
geom = "polygon",
40+
x = df$long, y = df$lat, group = df$group,
41+
fill = fill, colour = colour, ...
42+
)
43+
}
44+
45+
#' @export
46+
#' @rdname annotation_borders
47+
#' @usage borders(...) # Deprecated
48+
borders <- function(...) {
49+
deprecate_soft0("4.0.0", "borders()", "annotation_borders()")
50+
annotation_borders(...)
51+
}

R/annotation-custom.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ annotation_custom <- function(grob, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax =
5858
)
5959
}
6060

61-
#' @rdname ggplot2-ggproto
61+
#' @rdname Geom
6262
#' @format NULL
6363
#' @usage NULL
6464
#' @export

R/annotation-logticks.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#' @param scaled is the data already log-scaled? This should be `TRUE`
2525
#' (default) when the data is already transformed with `log10()` or when
2626
#' using `scale_y_log10()`. It should be `FALSE` when using
27-
#' `coord_trans(y = "log10")`.
27+
#' `coord_transform(y = "log10")`.
2828
#' @param colour Colour of the tick marks.
2929
#' @param linewidth Thickness of tick marks, in mm.
3030
#' @param linetype Linetype of tick marks (`solid`, `dashed`, etc.)
@@ -36,7 +36,7 @@
3636
#' @export
3737
#' @seealso [scale_y_continuous()], [scale_y_log10()] for log scale
3838
#' transformations.
39-
#' @seealso [coord_trans()] for log coordinate transformations.
39+
#' @seealso [coord_transform()] for log coordinate transformations.
4040
#'
4141
#' @examples
4242
#' # Make a log-log plot (without log ticks)
@@ -75,7 +75,7 @@
7575
#' # Using a coordinate transform requires scaled = FALSE
7676
#' t <- ggplot(msleep, aes(bodywt, brainwt)) +
7777
#' geom_point() +
78-
#' coord_trans(x = "log10", y = "log10") +
78+
#' coord_transform(x = "log10", y = "log10") +
7979
#' theme_bw()
8080
#' t + annotation_logticks(scaled = FALSE)
8181
#'
@@ -93,6 +93,8 @@ annotation_logticks <- function(base = 10, sides = "bl", outside = FALSE, scaled
9393
if (!is.null(color))
9494
colour <- color
9595

96+
lifecycle::signal_stage("superseded", "annotation_logticks()", "guide_axis_logticks()")
97+
9698
if (lifecycle::is_present(size)) {
9799
deprecate_soft0("3.5.0", I("Using the `size` aesthetic in this geom"), I("`linewidth`"))
98100
linewidth <- linewidth %||% size
@@ -123,7 +125,7 @@ annotation_logticks <- function(base = 10, sides = "bl", outside = FALSE, scaled
123125
)
124126
}
125127

126-
#' @rdname ggplot2-ggproto
128+
#' @rdname Geom
127129
#' @format NULL
128130
#' @usage NULL
129131
#' @export

R/annotation-map.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ annotation_map <- function(map, ...) {
7676
)
7777
}
7878

79-
#' @rdname ggplot2-ggproto
79+
#' @rdname Geom
8080
#' @format NULL
8181
#' @usage NULL
8282
#' @export

R/annotation-raster.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ annotation_raster <- function(raster, xmin, xmax, ymin, ymax,
6161

6262
}
6363

64-
#' @rdname ggplot2-ggproto
64+
#' @rdname Geom
6565
#' @format NULL
6666
#' @usage NULL
6767
#' @export

R/axis-secondary.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,19 @@ dup_axis <- function(transform = identity, name = derive(), breaks = derive(),
124124
sec_axis(transform, trans = trans, name, breaks, labels, guide)
125125
}
126126

127-
is.sec_axis <- function(x) {
127+
is_sec_axis <- function(x) {
128128
inherits(x, "AxisSecondary")
129129
}
130130

131131
set_sec_axis <- function(sec.axis, scale) {
132-
if (!is.waiver(sec.axis)) {
132+
if (!is_waiver(sec.axis)) {
133133
if (scale$is_discrete()) {
134134
if (!identical(.subset2(sec.axis, "trans"), identity)) {
135135
cli::cli_abort("Discrete secondary axes must have the {.fn identity} transformation.")
136136
}
137137
}
138-
if (is.formula(sec.axis)) sec.axis <- sec_axis(sec.axis)
139-
if (!is.sec_axis(sec.axis)) {
138+
if (is_formula(sec.axis)) sec.axis <- sec_axis(sec.axis)
139+
if (!is_sec_axis(sec.axis)) {
140140
cli::cli_abort("Secondary axes must be specified using {.fn sec_axis}.")
141141
}
142142
scale$secondary.axis <- sec.axis
@@ -150,7 +150,7 @@ set_sec_axis <- function(sec.axis, scale) {
150150
derive <- function() {
151151
structure(list(), class = "derived")
152152
}
153-
is.derived <- function(x) {
153+
is_derived <- function(x) {
154154
inherits(x, "derived")
155155
}
156156
#' @rdname ggplot2-ggproto
@@ -182,9 +182,9 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
182182
if (!is.function(transform)) {
183183
cli::cli_abort("Transformation for secondary axes must be a function.")
184184
}
185-
if (is.derived(self$name) && !is.waiver(scale$name)) self$name <- scale$name
186-
if (is.derived(self$breaks)) self$breaks <- scale$breaks
187-
if (is.waiver(self$breaks)) {
185+
if (is_derived(self$name) && !is_waiver(scale$name)) self$name <- scale$name
186+
if (is_derived(self$breaks)) self$breaks <- scale$breaks
187+
if (is_waiver(self$breaks)) {
188188
if (scale$is_discrete()) {
189189
self$breaks <- setNames(nm = scale$get_breaks())
190190
} else {
@@ -197,8 +197,8 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
197197
}
198198
}
199199
}
200-
if (is.derived(self$labels)) self$labels <- scale$labels
201-
if (is.derived(self$guide)) self$guide <- scale$guide
200+
if (is_derived(self$labels)) self$labels <- scale$labels
201+
if (is_derived(self$guide)) self$guide <- scale$guide
202202
},
203203

204204
transform_range = function(self, range) {

0 commit comments

Comments
 (0)