Skip to content

Commit 4424a3c

Browse files
committed
resolve merge conflict
Merge branch 'main' into aesthetics_roxy_tag # Conflicts: # R/geom-hex.R # R/geom-path.R # R/geom-polygon.R # R/geom-ribbon.R # R/geom-rug.R # R/stat-connect.R # R/stat-contour.R
2 parents 357aec6 + 863cb95 commit 4424a3c

File tree

251 files changed

+11460
-5417
lines changed

Some content is hidden

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

251 files changed

+11460
-5417
lines changed

DESCRIPTION

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Imports:
3939
isoband,
4040
lifecycle (> 1.0.1),
4141
rlang (>= 1.1.0),
42-
scales (>= 1.3.0),
42+
scales (>= 1.4.0),
4343
stats,
4444
vctrs (>= 0.6.0),
4545
withr (>= 2.5.0)
@@ -94,11 +94,15 @@ Collate:
9494
'compat-plyr.R'
9595
'utilities.R'
9696
'aes.R'
97+
'annotation-borders.R'
9798
'utilities-checks.R'
9899
'legend-draw.R'
99100
'geom-.R'
100101
'annotation-custom.R'
101102
'annotation-logticks.R'
103+
'scale-type.R'
104+
'layer.R'
105+
'make-constructor.R'
102106
'geom-polygon.R'
103107
'geom-map.R'
104108
'annotation-map.R'
@@ -143,6 +147,7 @@ Collate:
143147
'geom-col.R'
144148
'geom-path.R'
145149
'geom-contour.R'
150+
'geom-point.R'
146151
'geom-count.R'
147152
'geom-crossbar.R'
148153
'geom-segment.R'
@@ -161,7 +166,6 @@ Collate:
161166
'geom-jitter.R'
162167
'geom-label.R'
163168
'geom-linerange.R'
164-
'geom-point.R'
165169
'geom-pointrange.R'
166170
'geom-quantile.R'
167171
'geom-rug.R'
@@ -187,7 +191,6 @@ Collate:
187191
'guide-colorbar.R'
188192
'guide-colorsteps.R'
189193
'guide-custom.R'
190-
'layer.R'
191194
'guide-none.R'
192195
'guide-old.R'
193196
'guides-.R'
@@ -237,7 +240,6 @@ Collate:
237240
'scale-shape.R'
238241
'scale-size.R'
239242
'scale-steps.R'
240-
'scale-type.R'
241243
'scale-view.R'
242244
'scale-viridis.R'
243245
'scales-.R'

NAMESPACE

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ S3method(limits,character)
9696
S3method(limits,factor)
9797
S3method(limits,numeric)
9898
S3method(makeContext,dotstackGrob)
99+
S3method(make_constructor,Geom)
100+
S3method(make_constructor,Stat)
99101
S3method(merge_element,default)
100102
S3method(merge_element,element)
101103
S3method(merge_element,element_blank)
@@ -169,6 +171,7 @@ export(CoordQuickmap)
169171
export(CoordRadial)
170172
export(CoordSf)
171173
export(CoordTrans)
174+
export(CoordTransform)
172175
export(Facet)
173176
export(FacetGrid)
174177
export(FacetNull)
@@ -295,6 +298,7 @@ export(after_scale)
295298
export(after_stat)
296299
export(alpha)
297300
export(annotate)
301+
export(annotation_borders)
298302
export(annotation_custom)
299303
export(annotation_logticks)
300304
export(annotation_map)
@@ -323,6 +327,7 @@ export(coord_quickmap)
323327
export(coord_radial)
324328
export(coord_sf)
325329
export(coord_trans)
330+
export(coord_transform)
326331
export(cut_interval)
327332
export(cut_number)
328333
export(cut_width)
@@ -475,7 +480,6 @@ export(is.facet)
475480
export(is.ggplot)
476481
export(is.ggproto)
477482
export(is.theme)
478-
export(is.waiver)
479483
export(is_coord)
480484
export(is_facet)
481485
export(is_geom)
@@ -491,6 +495,7 @@ export(is_scale)
491495
export(is_stat)
492496
export(is_theme)
493497
export(is_theme_element)
498+
export(is_waiver)
494499
export(label_both)
495500
export(label_bquote)
496501
export(label_context)
@@ -506,6 +511,7 @@ export(layer_grob)
506511
export(layer_scales)
507512
export(layer_sf)
508513
export(lims)
514+
export(make_constructor)
509515
export(map_data)
510516
export(margin)
511517
export(margin_auto)

NEWS.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
* New roxygen tag `@aesthetics` that takes a Geom, Stat or Position class and
44
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).
514
* Facet gains a new method `setup_panel_params` to interact with the
615
panel_params setted by Coord object (@Yunuuuu, #6397, #6380)
716
* `position_fill()` avoids stacking observations of zero (@teunbrand, #6338)
@@ -89,7 +98,7 @@
8998
@yutannihilation's prior work, #3120)
9099
* When discrete breaks have names, they'll be used as labels by default
91100
(@teunbrand, #6147).
92-
* 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
93102
with `waiver()` objects (@arcresu, #6173).
94103
* Date(time) scales now throw appropriate errors when `date_breaks`,
95104
`date_minor_breaks` or `date_labels` are not strings (@RodDalBen, #5880)
@@ -280,6 +289,7 @@
280289
(@teunbrand, #5938, #4327).
281290
* Fixed bug where empty discrete scales weren't recognised as such
282291
(@teunbrand, #5945).
292+
* `coord_trans()` renamed to `coord_transform()` (@nmercadeb, #5825).
283293
* (internal) The summary function of `stat_summary()` and `stat_summary_bin()`
284294
is setup once in total instead of once per group (@teunbrand, #5971)
285295
* `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: 4 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
#'
@@ -123,7 +123,7 @@ annotation_logticks <- function(base = 10, sides = "bl", outside = FALSE, scaled
123123
)
124124
}
125125

126-
#' @rdname ggplot2-ggproto
126+
#' @rdname Geom
127127
#' @format NULL
128128
#' @usage NULL
129129
#' @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)