Skip to content

Commit 775b885

Browse files
committed
resolve merge conflict
Merge branch 'main' into S7_elements # Conflicts: # R/geom-label.R # R/guide-.R # R/guide-axis.R # R/margins.R # R/theme-elements.R # R/theme.R # man/element.Rd # man/is_tests.Rd # tests/testthat/test-theme.R
2 parents b2f143e + e1cdee0 commit 775b885

Some content is hidden

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

57 files changed

+2973
-25838
lines changed

Diff for: DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggplot2
2+
Version: 3.5.2.9000
23
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
3-
Version: 3.5.1.9000
44
Authors@R: c(
55
person("Hadley", "Wickham", , "[email protected]", role = "aut",
66
comment = c(ORCID = "0000-0003-4757-117X")),

Diff for: NAMESPACE

+16-11
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ S3method(predictdf,default)
9898
S3method(predictdf,glm)
9999
S3method(predictdf,locfit)
100100
S3method(predictdf,loess)
101+
S3method(print,element)
101102
S3method(print,ggplot)
102103
S3method(print,ggplot2_bins)
103104
S3method(print,ggproto)
@@ -460,22 +461,26 @@ export(guide_transform)
460461
export(guides)
461462
export(has_flipped_aes)
462463
export(is.Coord)
463-
export(is.coord)
464464
export(is.facet)
465-
export(is.geom)
466465
export(is.ggplot)
467466
export(is.ggproto)
468-
export(is.guide)
469-
export(is.guides)
470-
export(is.layer)
471-
export(is.mapping)
472-
export(is.margin)
473-
export(is.position)
474-
export(is.scale)
475-
export(is.stat)
476467
export(is.theme)
477-
export(is.theme_element)
478468
export(is.waiver)
469+
export(is_coord)
470+
export(is_facet)
471+
export(is_geom)
472+
export(is_ggplot)
473+
export(is_ggproto)
474+
export(is_guide)
475+
export(is_guides)
476+
export(is_layer)
477+
export(is_mapping)
478+
export(is_margin)
479+
export(is_position)
480+
export(is_scale)
481+
export(is_stat)
482+
export(is_theme)
483+
export(is_theme_element)
479484
export(label_both)
480485
export(label_bquote)
481486
export(label_context)

Diff for: NEWS.md

+754-733
Large diffs are not rendered by default.

Diff for: R/aes.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ aes <- function(x, y, ...) {
111111

112112
#' @export
113113
#' @rdname is_tests
114-
is.mapping <- function(x) inherits(x, "uneval")
114+
is_mapping <- function(x) inherits(x, "uneval")
115115

116116
# Wrap symbolic objects in quosures but pull out constants out of
117117
# quosures for backward-compatibility

Diff for: R/bin.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ compute_bins <- function(x, scale = NULL, breaks = NULL, binwidth = NULL, bins =
120120
center = NULL, boundary = NULL,
121121
closed = c("right", "left")) {
122122

123-
range <- if (is.scale(scale)) scale$dimension() else range(x)
123+
range <- if (is_scale(scale)) scale$dimension() else range(x)
124124
check_length(range, 2L)
125125

126126
if (!is.null(breaks)) {
127127
breaks <- allow_lambda(breaks)
128128
if (is.function(breaks)) {
129129
breaks <- breaks(x)
130130
}
131-
if (is.scale(scale) && !scale$is_discrete()) {
131+
if (is_scale(scale) && !scale$is_discrete()) {
132132
breaks <- scale$transform(breaks)
133133
}
134134
check_numeric(breaks)

Diff for: R/coord-.R

+3-4
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,16 @@ Coord <- ggproto("Coord",
225225
}
226226
)
227227

228-
229228
#' @export
230229
#' @rdname is_tests
231-
is.coord <- function(x) inherits(x, "Coord")
230+
is_coord <- function(x) inherits(x, "Coord")
232231

233232
#' @export
234233
#' @rdname is_tests
235234
#' @usage is.Coord(x) # Deprecated
236235
is.Coord <- function(x) {
237-
deprecate_soft0("3.5.2", "is.Coord()", "is.coord()")
238-
is.coord(x)
236+
deprecate_soft0("3.5.2", "is.Coord()", "is_coord()")
237+
is_coord(x)
239238
}
240239

241240
# Renders an axis with the correct orientation or zeroGrob if no axis should be

Diff for: R/coord-cartesian-.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ view_scales_from_scale <- function(scale, coord_limits = NULL, expand = TRUE) {
165165
}
166166

167167
panel_guides_grob <- function(guides, position, theme, labels = NULL) {
168-
if (!is.guides(guides)) {
168+
if (!is_guides(guides)) {
169169
return(zeroGrob())
170170
}
171171
pair <- guides$get_position(position)

Diff for: R/coord-radial.R

+32-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#' @param end Position from 12 o'clock in radians where plot ends, to allow
55
#' for partial polar coordinates. The default, `NULL`, is set to
66
#' `start + 2 * pi`.
7+
#' @param thetalim,rlim Limits for the theta and r axes.
78
#' @param expand If `TRUE`, the default, adds a small expansion factor to
89
#' the limits to prevent overlap between data and axes. If `FALSE`, limits
910
#' are taken directly from the scale.
@@ -40,9 +41,19 @@
4041
#' ggplot(mtcars, aes(disp, mpg)) +
4142
#' geom_point() +
4243
#' coord_radial(start = -0.4 * pi, end = 0.4 * pi, inner.radius = 0.3)
44+
#'
45+
#' # Similar with coord_cartesian(), you can set limits.
46+
#' ggplot(mtcars, aes(disp, mpg)) +
47+
#' geom_point() +
48+
#' coord_radial(
49+
#' start = -0.4 * pi,
50+
#' end = 0.4 * pi, inner.radius = 0.3,
51+
#' thetalim = c(200, 300),
52+
#' rlim = c(15, 30),
53+
#' )
4354
coord_radial <- function(theta = "x",
4455
start = 0, end = NULL,
45-
expand = TRUE,
56+
thetalim = NULL, rlim = NULL, expand = TRUE,
4657
direction = deprecated(),
4758
clip = "off",
4859
r.axis.inside = NULL,
@@ -96,6 +107,7 @@ coord_radial <- function(theta = "x",
96107
inner.radius <- switch(reverse, thetar = , r = rev, identity)(inner.radius)
97108

98109
ggproto(NULL, CoordRadial,
110+
limits = list(theta = thetalim, r = rlim),
99111
theta = theta,
100112
r = r,
101113
arc = arc,
@@ -147,10 +159,20 @@ CoordRadial <- ggproto("CoordRadial", Coord,
147159
},
148160

149161
setup_panel_params = function(self, scale_x, scale_y, params = list()) {
150-
162+
if (self$theta == "x") {
163+
xlimits <- self$limits$theta
164+
ylimits <- self$limits$r
165+
} else {
166+
xlimits <- self$limits$r
167+
ylimits <- self$limits$theta
168+
}
151169
params <- c(
152-
view_scales_polar(scale_x, self$theta, expand = params$expand[c(4, 2)]),
153-
view_scales_polar(scale_y, self$theta, expand = params$expand[c(3, 1)]),
170+
view_scales_polar(scale_x, self$theta, xlimits,
171+
expand = params$expand[c(4, 2)]
172+
),
173+
view_scales_polar(scale_y, self$theta, ylimits,
174+
expand = params$expand[c(3, 1)]
175+
),
154176
list(bbox = polar_bbox(self$arc, inner_radius = self$inner_radius),
155177
arc = self$arc, inner_radius = self$inner_radius)
156178
)
@@ -454,15 +476,19 @@ CoordRadial <- ggproto("CoordRadial", Coord,
454476
}
455477
)
456478

457-
view_scales_polar <- function(scale, theta = "x", expand = TRUE) {
479+
view_scales_polar <- function(scale, theta = "x", coord_limits = NULL,
480+
expand = TRUE) {
458481

459482
aesthetic <- scale$aesthetics[1]
460483
is_theta <- theta == aesthetic
461484
name <- if (is_theta) "theta" else "r"
462485

463486
expansion <- default_expansion(scale, expand = expand)
464487
limits <- scale$get_limits()
465-
continuous_range <- expand_limits_scale(scale, expansion, limits)
488+
continuous_range <- expand_limits_scale(
489+
scale, expansion, limits,
490+
coord_limits
491+
)
466492

467493
primary <- view_scale_primary(scale, limits, continuous_range)
468494
view_scales <- list(

Diff for: R/facet-.R

+20-7
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ NULL
99
#' rendered.
1010
#'
1111
#' Extending facets can range from the simple modifications of current facets,
12-
#' to very laborious rewrites with a lot of [gtable()] manipulation.
13-
#' For some examples of both, please see the extension vignette.
12+
#' to very laborious rewrites with a lot of [`gtable()`][gtable::gtable()]
13+
#' manipulation. For some examples of both, please see the extension vignette.
1414
#'
1515
#' `Facet` subclasses, like other extendible ggproto classes, have a range
1616
#' of methods that can be modified. Some of these are required for all new
@@ -46,6 +46,10 @@ NULL
4646
#' the default behaviour of one or more of the following methods:
4747
#'
4848
#' - `setup_params`:
49+
#'
50+
#' - `setup_panel_params`: modifies the x and y ranges for each panel. This is
51+
#' used to allow the `Facet` to interact with the `panel_params`.
52+
#'
4953
#' - `init_scales`: Given a master scale for x and y, create panel
5054
#' specific scales for each panel defined in the layout. The default is to
5155
#' simply clone the master scale.
@@ -90,6 +94,7 @@ Facet <- ggproto("Facet", NULL,
9094
map_data = function(data, layout, params) {
9195
cli::cli_abort("Not implemented.")
9296
},
97+
setup_panel_params = function(self, panel_params, coord, ...) panel_params,
9398
init_scales = function(layout, x_scale = NULL, y_scale = NULL, params) {
9499
scales <- list()
95100
if (!is.null(x_scale)) {
@@ -313,10 +318,6 @@ Facet <- ggproto("Facet", NULL,
313318
}
314319
)
315320

316-
#' @export
317-
#' @rdname is_tests
318-
is.facet <- function(x) inherits(x, "Facet")
319-
320321
# Helpers -----------------------------------------------------------------
321322

322323
#' Quote faceting variables
@@ -378,6 +379,18 @@ vars <- function(...) {
378379
quos(...)
379380
}
380381

382+
#' @export
383+
#' @rdname is_tests
384+
is_facet <- function(x) inherits(x, "Facet")
385+
386+
#' @export
387+
#' @rdname is_tests
388+
#' @usage is.facet(x) # Deprecated
389+
is.facet <- function(x) {
390+
deprecate_soft0("3.5.2", "is.facet()", "is_facet()")
391+
is_facet(x)
392+
}
393+
381394
#' Accessing a plot's facet strip labels
382395
#'
383396
#' This functions retrieves labels from facet strips with the labeller applied.
@@ -488,7 +501,7 @@ as_facets_list <- function(x) {
488501
}
489502

490503
check_vars <- function(x) {
491-
if (is.mapping(x)) {
504+
if (is_mapping(x)) {
492505
cli::cli_abort("Please use {.fn vars} to supply facet variables.")
493506
}
494507
# Native pipe have higher precedence than + so any type of gg object can be

Diff for: R/fortify.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fortify.default <- function(model, data, ...) {
9494
"or an object coercible by {.fn fortify}, or a valid ",
9595
"{.cls data.frame}-like object coercible by {.fn as.data.frame}"
9696
)
97-
if (is.mapping(model)) {
97+
if (is_mapping(model)) {
9898
msg <- c(
9999
paste0(msg, ", not ", obj_type_friendly(model), "."),
100100
"i" = "Did you accidentally pass {.fn aes} to the {.arg data} argument?"

Diff for: R/geom-.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ Geom <- ggproto("Geom",
237237

238238
#' @export
239239
#' @rdname is_tests
240-
is.geom <- function(x) inherits(x, "Geom")
240+
is_geom <- function(x) inherits(x, "Geom")
241241

242242
eval_from_theme <- function(aesthetics, theme, class = NULL) {
243243
themed <- is_themed_aes(aesthetics)

Diff for: R/geom-defaults.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ update_stat_defaults <- function(stat, new) {
9393
#'
9494
#' # Changed theme
9595
#' get_geom_defaults("point", theme(geom = element_geom(ink = "purple")))
96-
get_geom_defaults <- function(geom, theme = theme_get()) {
96+
get_geom_defaults <- function(geom, theme = get_theme()) {
9797
theme <- theme %||% list(geom = .default_geom_element)
9898

9999
if (is.function(geom)) {
100100
geom <- geom()
101101
}
102-
if (is.layer(geom)) {
102+
if (is_layer(geom)) {
103103
data <- data_frame0(.id = 1L)
104104
data <- geom$compute_geom_2(data = data, theme = theme)
105105
data$.id <- NULL
@@ -108,7 +108,7 @@ get_geom_defaults <- function(geom, theme = theme_get()) {
108108
if (is.character(geom)) {
109109
geom <- validate_subclass(geom, "Geom")
110110
}
111-
if (is.geom(geom)) {
111+
if (is_geom(geom)) {
112112
out <- geom$use_defaults(data = NULL, theme = theme)
113113
return(out)
114114
}

Diff for: R/geom-label.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ GeomLabel <- ggproto("GeomLabel", Geom,
8888
data <- coord$transform(data, panel_params)
8989
data$vjust <- compute_just(data$vjust, data$y, data$x, data$angle)
9090
data$hjust <- compute_just(data$hjust, data$x, data$y, data$angle)
91-
if (!is.margin(label.padding)) {
91+
92+
if (!is_margin(label.padding)) {
9293
label.padding <- rep(label.padding, length.out = 4)
9394
}
9495

Diff for: R/ggproto.R

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' Create a new ggproto object
22
#'
3-
#' Construct a new object with `ggproto()`, test with `is.ggproto()`,
3+
#' Construct a new object with `ggproto()`, test with `is_ggproto()`,
44
#' and access parent methods/fields with `ggproto_parent()`.
55
#'
66
#' ggproto implements a protype based OO system which blurs the lines between
@@ -52,7 +52,7 @@
5252
#' self$x
5353
#' }
5454
#' )
55-
#' is.ggproto(Adder)
55+
#' is_ggproto(Adder)
5656
#'
5757
#' Adder$add(10)
5858
#' Adder$add(10)
@@ -88,7 +88,7 @@ ggproto <- function(`_class` = NULL, `_inherit` = NULL, ...) {
8888

8989
super <- find_super()
9090
if (!is.null(super)) {
91-
check_object(super, is.ggproto, "a {.cls ggproto} object", arg = "_inherit")
91+
check_object(super, is_ggproto, "a {.cls ggproto} object", arg = "_inherit")
9292
e$super <- find_super
9393
class(e) <- c(`_class`, class(super))
9494
} else {
@@ -98,17 +98,25 @@ ggproto <- function(`_class` = NULL, `_inherit` = NULL, ...) {
9898
e
9999
}
100100

101-
#' @export
102-
#' @rdname is_tests
103-
is.ggproto <- function(x) inherits(x, "ggproto")
104-
105101
#' @export
106102
#' @rdname ggproto
107103
#' @param parent,self Access parent class `parent` of object `self`.
108104
ggproto_parent <- function(parent, self) {
109105
structure(list(parent = parent, self = self), class = "ggproto_parent")
110106
}
111107

108+
#' @export
109+
#' @rdname is_tests
110+
is_ggproto <- function(x) inherits(x, "ggproto")
111+
112+
#' @export
113+
#' @rdname is_tests
114+
#' @usage is.ggproto(x) # Deprecated
115+
is.ggproto <- function(x) {
116+
deprecate_soft0("3.5.2", "is.ggproto()", "is_ggproto()")
117+
is_ggproto(x)
118+
}
119+
112120
fetch_ggproto <- function(x, name) {
113121
res <- NULL
114122

@@ -303,7 +311,7 @@ object_summaries <- function(x, exclude = NULL, flat = TRUE) {
303311
values <- vapply(obj_names, function(name) {
304312
obj <- x[[name]]
305313
if (is.function(obj)) "function"
306-
else if (is.ggproto(obj)) format(obj, flat = flat)
314+
else if (is_ggproto(obj)) format(obj, flat = flat)
307315
else if (is.environment(obj)) "environment"
308316
else if (is.null(obj)) "NULL"
309317
else if (is.atomic(obj)) trim(paste(as.character(obj), collapse = " "))

0 commit comments

Comments
 (0)