Skip to content

Commit e57124f

Browse files
committed
Merge branch 'main' into absorb_coord_fixed
2 parents 4675fc7 + 863cb95 commit e57124f

File tree

247 files changed

+11402
-5335
lines changed

Some content is hidden

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

247 files changed

+11402
-5335
lines changed

DESCRIPTION

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,15 @@ Collate:
9393
'compat-plyr.R'
9494
'utilities.R'
9595
'aes.R'
96+
'annotation-borders.R'
9697
'utilities-checks.R'
9798
'legend-draw.R'
9899
'geom-.R'
99100
'annotation-custom.R'
100101
'annotation-logticks.R'
102+
'scale-type.R'
103+
'layer.R'
104+
'make-constructor.R'
101105
'geom-polygon.R'
102106
'geom-map.R'
103107
'annotation-map.R'
@@ -142,6 +146,7 @@ Collate:
142146
'geom-col.R'
143147
'geom-path.R'
144148
'geom-contour.R'
149+
'geom-point.R'
145150
'geom-count.R'
146151
'geom-crossbar.R'
147152
'geom-segment.R'
@@ -160,7 +165,6 @@ Collate:
160165
'geom-jitter.R'
161166
'geom-label.R'
162167
'geom-linerange.R'
163-
'geom-point.R'
164168
'geom-pointrange.R'
165169
'geom-quantile.R'
166170
'geom-rug.R'
@@ -186,7 +190,6 @@ Collate:
186190
'guide-colorbar.R'
187191
'guide-colorsteps.R'
188192
'guide-custom.R'
189-
'layer.R'
190193
'guide-none.R'
191194
'guide-old.R'
192195
'guides-.R'
@@ -236,7 +239,6 @@ Collate:
236239
'scale-shape.R'
237240
'scale-size.R'
238241
'scale-steps.R'
239-
'scale-type.R'
240242
'scale-view.R'
241243
'scale-viridis.R'
242244
'scales-.R'

NAMESPACE

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ S3method(limits,character)
9595
S3method(limits,factor)
9696
S3method(limits,numeric)
9797
S3method(makeContext,dotstackGrob)
98+
S3method(make_constructor,Geom)
99+
S3method(make_constructor,Stat)
98100
S3method(merge_element,default)
99101
S3method(merge_element,element)
100102
S3method(merge_element,element_blank)
@@ -168,6 +170,7 @@ export(CoordQuickmap)
168170
export(CoordRadial)
169171
export(CoordSf)
170172
export(CoordTrans)
173+
export(CoordTransform)
171174
export(Facet)
172175
export(FacetGrid)
173176
export(FacetNull)
@@ -294,6 +297,7 @@ export(after_scale)
294297
export(after_stat)
295298
export(alpha)
296299
export(annotate)
300+
export(annotation_borders)
297301
export(annotation_custom)
298302
export(annotation_logticks)
299303
export(annotation_map)
@@ -322,6 +326,7 @@ export(coord_quickmap)
322326
export(coord_radial)
323327
export(coord_sf)
324328
export(coord_trans)
329+
export(coord_transform)
325330
export(cut_interval)
326331
export(cut_number)
327332
export(cut_width)
@@ -474,7 +479,6 @@ export(is.facet)
474479
export(is.ggplot)
475480
export(is.ggproto)
476481
export(is.theme)
477-
export(is.waiver)
478482
export(is_coord)
479483
export(is_facet)
480484
export(is_geom)
@@ -490,6 +494,7 @@ export(is_scale)
490494
export(is_stat)
491495
export(is_theme)
492496
export(is_theme_element)
497+
export(is_waiver)
493498
export(label_both)
494499
export(label_bquote)
495500
export(label_context)
@@ -505,6 +510,7 @@ export(layer_grob)
505510
export(layer_scales)
506511
export(layer_sf)
507512
export(lims)
513+
export(make_constructor)
508514
export(map_data)
509515
export(margin)
510516
export(margin_auto)

NEWS.md

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

33
* New `coord_cartesian(ratio)` argument that supersedes `coord_fixed()` and
44
`coord_equal()`.
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)
512
* (internal) New `Facet$draw_panel_content()` method for delegating panel
613
assembly (@Yunuuuu, #6406).
714
* Facet gains a new method `setup_panel_params` to interact with the
@@ -91,7 +98,7 @@
9198
@yutannihilation's prior work, #3120)
9299
* When discrete breaks have names, they'll be used as labels by default
93100
(@teunbrand, #6147).
94-
* 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
95102
with `waiver()` objects (@arcresu, #6173).
96103
* Date(time) scales now throw appropriate errors when `date_breaks`,
97104
`date_minor_breaks` or `date_labels` are not strings (@RodDalBen, #5880)
@@ -282,6 +289,7 @@
282289
(@teunbrand, #5938, #4327).
283290
* Fixed bug where empty discrete scales weren't recognised as such
284291
(@teunbrand, #5945).
292+
* `coord_trans()` renamed to `coord_transform()` (@nmercadeb, #5825).
285293
* (internal) The summary function of `stat_summary()` and `stat_summary_bin()`
286294
is setup once in total instead of once per group (@teunbrand, #5971)
287295
* `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)