Skip to content

Commit 9547856

Browse files
authored
Merge branch 'main' into zero_width_binning
2 parents 4eb20b8 + 321b300 commit 9547856

File tree

128 files changed

+1779
-629
lines changed

Some content is hidden

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

128 files changed

+1779
-629
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ Collate:
274274
'theme.R'
275275
'theme-defaults.R'
276276
'theme-current.R'
277+
'theme-sub.R'
277278
'utilities-break.R'
278279
'utilities-grid.R'
279280
'utilities-help.R'

NAMESPACE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,17 @@ export(theme_linedraw)
725725
export(theme_minimal)
726726
export(theme_replace)
727727
export(theme_set)
728+
export(theme_sub_axis)
729+
export(theme_sub_axis_bottom)
730+
export(theme_sub_axis_left)
731+
export(theme_sub_axis_right)
732+
export(theme_sub_axis_top)
733+
export(theme_sub_axis_x)
734+
export(theme_sub_axis_y)
735+
export(theme_sub_legend)
736+
export(theme_sub_panel)
737+
export(theme_sub_plot)
738+
export(theme_sub_strip)
728739
export(theme_test)
729740
export(theme_transparent)
730741
export(theme_update)

NEWS.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
* Binned scales with zero-width data expand the default limits by 0.1
44
(@teunbrand, #5066)
5+
* New default `geom_qq_line(geom = "abline")` for better clipping in the
6+
vertical direction. In addition, `slope` and `intercept` are new computed
7+
variables in `stat_qq_line()` (@teunbrand, #6087).
8+
* Position adjustments can now have auxiliary aesthetics (@teunbrand).
9+
* `position_nudge()` gains `nudge_x` and `nudge_y` aesthetics (#3026, #5445).
10+
* `position_dodge()` gains `order` aesthetic (#3022, #3345)
11+
* More stability for vctrs-based palettes (@teunbrand, #6117).
12+
* Fixed regression in `guide_bins(reverse = TRUE)` (@teunbrand, #6183).
13+
* New function family for setting parts of a theme. For example, you can now use
14+
`theme_sub_axis(line, text, ticks, ticks.length, line)` as a substitute for
15+
`theme(axis.line, axis.text, axis.ticks, axis.ticks.length, axis.line)`. This
16+
should allow slightly terser and more organised theme declarations
17+
(@teunbrand, #5301).
18+
* `scale_{x/y}_discrete(continuous.limits)` is a new argument to control the
19+
display range of discrete scales (@teunbrand, #4174, #6259).
20+
* `geom_ribbon()` now appropriately warns about, and removes, missing values
21+
(@teunbrand, #6243).
522
* `guide_*()` can now accept two inside legend theme elements:
623
`legend.position.inside` and `legend.justification.inside`, allowing inside
724
legends to be placed at different positions. Only inside legends with the same
@@ -44,6 +61,13 @@
4461
(@teunbrand, #4320)
4562
* `geom_boxplot()` gains additional arguments to style the colour, linetype and
4663
linewidths of the box, whiskers, median line and staples (@teunbrand, #5126)
64+
* `geom_violin()` gains additional arguments to style the colour, linetype and
65+
linewidths of the quantiles, which replace the now-deprecated `draw_quantiles`
66+
argument (#5912).
67+
* (breaking) `geom_violin(quantiles)` now has actual quantiles based on
68+
the data, rather than inferred quantiles based on the computed density. The
69+
`quantiles` parameter that replaces `draw_quantiles` now belongs to
70+
`stat_ydensity()` instead of `geom_violin()` (@teunbrand, #4120).
4771
* (internal) Using `after_scale()` in the `Geom*$default_aes()` field is now
4872
evaluated in the context of data (@teunbrand, #6135)
4973
* Fixed bug where binned scales wouldn't simultaneously accept transformations
@@ -245,6 +269,11 @@
245269
* `geom_abline()` clips to the panel range in the vertical direction too
246270
(@teunbrand, #6086).
247271
* Added `panel.widths` and `panel.heights` to `theme()` (#5338, @teunbrand).
272+
* Standardised the calculation of `width`, which are now implemented as
273+
aesthetics (@teunbrand, #2800).
274+
* Stricter check on `register_theme_elements(element_tree)` (@teunbrand, #6162)
275+
* Added `weight` aesthetic for `stat_ellipse()` (@teunbrand, #5272)
276+
* Fixed a bug where the `guide_custom(order)` wasn't working (@teunbrand, #6195)
248277

249278
# ggplot2 3.5.1
250279

R/aes.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ NULL
3838
#'
3939
#' [Delayed evaluation][aes_eval] for working with computed variables.
4040
#'
41+
#' @note
42+
#' Using `I()` to create objects of class 'AsIs' causes scales to ignore the
43+
#' variable and assumes the wrapped variable is direct input for the grid
44+
#' package. Please be aware that variables are sometimes combined, like in
45+
#' some stats or position adjustments, that may yield unexpected results with
46+
#' 'AsIs' variables.
47+
#'
4148
#' @family aesthetics documentation
4249
#' @return A list with class `uneval`. Components of the list are either
4350
#' quosures or constants.

R/coord-radial.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +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 expand If `TRUE`, the default, adds a small expansion factor the
7+
#' @param expand If `TRUE`, the default, adds a small expansion factor to
88
#' the limits to prevent overlap between data and axes. If `FALSE`, limits
99
#' are taken directly from the scale.
1010
#' @param r.axis.inside One of the following:
@@ -27,10 +27,10 @@
2727
#' @param r_axis_inside,rotate_angle `r lifecycle::badge("deprecated")`
2828
#'
2929
#' @note
30-
#' In `coord_radial()`, position guides are can be defined by using
30+
#' In `coord_radial()`, position guides can be defined by using
3131
#' `guides(r = ..., theta = ..., r.sec = ..., theta.sec = ...)`. Note that
3232
#' these guides require `r` and `theta` as available aesthetics. The classic
33-
#' `guide_axis()` can be used for the `r` positions and `guide_axis_theta()` can
33+
#' [guide_axis()] can be used for the `r` positions and [guide_axis_theta()] can
3434
#' be used for the `theta` positions. Using the `theta.sec` position is only
3535
#' sensible when `inner.radius > 0`.
3636
#'
@@ -191,7 +191,7 @@ CoordRadial <- ggproto("CoordRadial", Coord,
191191
# Validate appropriateness of guides
192192
drop_guides <- character(0)
193193
for (type in aesthetics) {
194-
drop_guides <- check_polar_guide(drop_guides, guides, type)
194+
drop_guides <- validate_polar_guide(drop_guides, guides, type)
195195
}
196196

197197
guide_params <- guides$get_params(aesthetics)
@@ -603,7 +603,7 @@ theta_grid <- function(theta, element, inner_radius = c(0, 0.4),
603603
)
604604
}
605605

606-
check_polar_guide <- function(drop_list, guides, type = "theta") {
606+
validate_polar_guide <- function(drop_list, guides, type = "theta") {
607607
guide <- guides$get_guide(type)
608608
primary <- gsub("\\.sec$", "", type)
609609
if (inherits(guide, "GuideNone") || primary %in% guide$available_aes) {

R/facet-.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ df.grid <- function(a, b) {
443443
# facetting variables.
444444

445445
as_facets_list <- function(x) {
446-
x <- validate_facets(x)
446+
check_vars(x)
447447
if (is_quosures(x)) {
448448
x <- quos_auto_name(x)
449449
return(list(x))
@@ -487,7 +487,7 @@ as_facets_list <- function(x) {
487487
x
488488
}
489489

490-
validate_facets <- function(x) {
490+
check_vars <- function(x) {
491491
if (is.mapping(x)) {
492492
cli::cli_abort("Please use {.fn vars} to supply facet variables.")
493493
}
@@ -499,7 +499,7 @@ validate_facets <- function(x) {
499499
"i" = "Did you use {.code %>%} or {.code |>} instead of {.code +}?"
500500
))
501501
}
502-
x
502+
invisible()
503503
}
504504

505505
# Flatten a list of quosures objects to a quosures object, and compact it

R/facet-grid-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ facet_grid <- function(rows = NULL, cols = NULL, scales = "fixed",
177177
facets_list <- grid_as_facets_list(rows, cols)
178178

179179
# Check for deprecated labellers
180-
labeller <- check_labeller(labeller)
180+
labeller <- fix_labeller(labeller)
181181

182182
ggproto(NULL, FacetGrid,
183183
shrink = shrink,

R/facet-wrap.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
174174
)
175175

176176
# Check for deprecated labellers
177-
labeller <- check_labeller(labeller)
177+
labeller <- fix_labeller(labeller)
178178

179179
# Flatten all facets dimensions into a single one
180180
facets <- compact_facets(facets)

R/fortify-map.R

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#' Fortify method for map objects
22
#'
3+
#' @description
4+
#' `r lifecycle::badge("deprecated")`
5+
#'
36
#' This function turns a map into a data frame that can more easily be
47
#' plotted with ggplot2.
58
#'
@@ -24,6 +27,9 @@
2427
#' geom_polygon(aes(group = group), colour = "white")
2528
#' }
2629
fortify.map <- function(model, data, ...) {
30+
lifecycle::deprecate_warn(
31+
"3.6.0", I("`fortify(<map>)`"), "map_data()"
32+
)
2733
df <- data_frame0(
2834
long = model$x,
2935
lat = model$y,
@@ -46,10 +52,10 @@ fortify.map <- function(model, data, ...) {
4652
#' for plotting with ggplot2.
4753
#'
4854
#' @param map name of map provided by the \pkg{maps} package. These
49-
#' include [maps::county()], [maps::france()],
50-
#' [maps::italy()], [maps::nz()],
51-
#' [maps::state()], [maps::usa()],
52-
#' [maps::world()], [maps::world2()].
55+
#' include [`"county"`][maps::county], [`"france"`][maps::france],
56+
#' [`"italy"`][maps::italy], [`"nz"`][maps::nz],
57+
#' [`"state"`][maps::state], [`"usa"`][maps::usa],
58+
#' [`"world"`][maps::world], or [`"world2"`][maps::world2].
5359
#' @param region name(s) of subregion(s) to include. Defaults to `.` which
5460
#' includes all subregions. See documentation for [maps::map()]
5561
#' for more details.
@@ -80,7 +86,27 @@ fortify.map <- function(model, data, ...) {
8086
map_data <- function(map, region = ".", exact = FALSE, ...) {
8187
check_installed("maps", reason = "for `map_data()`.")
8288
map_obj <- maps::map(map, region, exact = exact, plot = FALSE, fill = TRUE, ...)
83-
fortify(map_obj)
89+
90+
if (!inherits(map_obj, "map")) {
91+
cli::cli_abort(c(
92+
"{.fn maps::map} must return an object of type {.cls map}, not \\
93+
{obj_type_friendly(map_obj)}.",
94+
i = "Did you pass the right arguments?"
95+
))
96+
}
97+
98+
df <- data_frame0(
99+
long = map_obj$x,
100+
lat = map_obj$y,
101+
group = cumsum(is.na(map_obj$x) & is.na(map_obj$y)) + 1,
102+
order = seq_along(map_obj$x),
103+
.size = length(map_obj$x)
104+
)
105+
106+
names <- lapply(strsplit(map_obj$names, "[:,]"), "[", 1:2)
107+
names <- vec_rbind(!!!names, .name_repair = ~ c("region", "subregion"))
108+
df[names(names)] <- vec_slice(names, df$group)
109+
vec_slice(df, stats::complete.cases(df$lat, df$long))
84110
}
85111

86112
#' Create a layer of map borders

R/fortify-spatial.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#' Fortify method for classes from the sp package.
22
#'
3+
#' @description
4+
#' `r lifecycle::badge("deprecated")`
5+
#'
36
#' To figure out the correct variable name for region, inspect
47
#' `as.data.frame(model)`.
58
#'

0 commit comments

Comments
 (0)