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

DESCRIPTION

Lines changed: 1 addition & 1 deletion
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")),

NAMESPACE

Lines changed: 16 additions & 11 deletions
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)

NEWS.md

Lines changed: 754 additions & 733 deletions
Large diffs are not rendered by default.

R/aes.R

Lines changed: 1 addition & 1 deletion
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

R/bin.R

Lines changed: 2 additions & 2 deletions
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)

R/coord-.R

Lines changed: 3 additions & 4 deletions
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

R/coord-cartesian-.R

Lines changed: 1 addition & 1 deletion
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)

R/coord-radial.R

Lines changed: 32 additions & 6 deletions
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(

R/facet-.R

Lines changed: 20 additions & 7 deletions
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

R/fortify.R

Lines changed: 1 addition & 1 deletion
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?"

0 commit comments

Comments
 (0)