Skip to content

Commit 6f2f53c

Browse files
committed
Merge branch 'main' into geom_abline_clipping
2 parents 09476d0 + 918821a commit 6f2f53c

File tree

266 files changed

+4551
-2520
lines changed

Some content is hidden

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

266 files changed

+4551
-2520
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
cache-version: 3
6464
extra-packages: >
6565
any::rcmdcheck,
66-
Hmisc=?ignore-before-r=4.1.0,
66+
Hmisc=?ignore-before-r=4.2.0,
6767
quantreg=?ignore-before-r=4.3.0
6868
needs: check
6969

DESCRIPTION

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggplot2
2-
Version: 3.5.1.9000
32
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")),
@@ -30,21 +30,21 @@ License: MIT + file LICENSE
3030
URL: https://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2
3131
BugReports: https://github.com/tidyverse/ggplot2/issues
3232
Depends:
33-
R (>= 3.5)
33+
R (>= 4.0)
3434
Imports:
3535
cli,
3636
grDevices,
3737
grid,
3838
gtable (>= 0.1.1),
3939
isoband,
4040
lifecycle (> 1.0.1),
41-
MASS,
4241
rlang (>= 1.1.0),
4342
scales (>= 1.3.0),
4443
stats,
4544
vctrs (>= 0.6.0),
4645
withr (>= 2.5.0)
4746
Suggests:
47+
broom,
4848
covr,
4949
dplyr,
5050
ggplot2movies,
@@ -53,6 +53,7 @@ Suggests:
5353
knitr,
5454
mapproj,
5555
maps,
56+
MASS,
5657
mgcv,
5758
multcomp,
5859
munsell,
@@ -75,6 +76,7 @@ VignetteBuilder:
7576
knitr
7677
Config/Needs/website: ggtext, tidyr, forcats, tidyverse/tidytemplate
7778
Config/testthat/edition: 3
79+
Config/usethis/last-upkeep: 2024-10-24
7880
Encoding: UTF-8
7981
LazyData: true
8082
Roxygen: list(markdown = TRUE)
@@ -125,15 +127,15 @@ Collate:
125127
'facet-grid-.R'
126128
'facet-null.R'
127129
'facet-wrap.R'
128-
'fortify-lm.R'
129130
'fortify-map.R'
130-
'fortify-multcomp.R'
131+
'fortify-models.R'
131132
'fortify-spatial.R'
132133
'fortify.R'
133134
'stat-.R'
134135
'geom-abline.R'
135136
'geom-rect.R'
136137
'geom-bar.R'
138+
'geom-tile.R'
137139
'geom-bin2d.R'
138140
'geom-blank.R'
139141
'geom-boxplot.R'
@@ -150,7 +152,6 @@ Collate:
150152
'geom-density2d.R'
151153
'geom-dotplot.R'
152154
'geom-errorbar.R'
153-
'geom-errorbarh.R'
154155
'geom-freqpoly.R'
155156
'geom-function.R'
156157
'geom-hex.R'
@@ -167,7 +168,6 @@ Collate:
167168
'geom-smooth.R'
168169
'geom-spoke.R'
169170
'geom-text.R'
170-
'geom-tile.R'
171171
'geom-violin.R'
172172
'geom-vline.R'
173173
'ggplot2-package.R'

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright (c) 2020 ggplot2 authors
3+
Copyright (c) 2024 ggplot2 core developer team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

NAMESPACE

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export(GeomAbline)
172172
export(GeomAnnotationMap)
173173
export(GeomArea)
174174
export(GeomBar)
175+
export(GeomBin2d)
175176
export(GeomBlank)
176177
export(GeomBoxplot)
177178
export(GeomCol)
@@ -461,7 +462,6 @@ export(guides)
461462
export(has_flipped_aes)
462463
export(is.Coord)
463464
export(is.coord)
464-
export(is.element)
465465
export(is.facet)
466466
export(is.geom)
467467
export(is.ggplot)
@@ -475,6 +475,8 @@ export(is.position)
475475
export(is.scale)
476476
export(is.stat)
477477
export(is.theme)
478+
export(is.theme_element)
479+
export(is.waiver)
478480
export(label_both)
479481
export(label_bquote)
480482
export(label_context)
@@ -719,6 +721,7 @@ export(theme_minimal)
719721
export(theme_replace)
720722
export(theme_set)
721723
export(theme_test)
724+
export(theme_transparent)
722725
export(theme_update)
723726
export(theme_void)
724727
export(transform_position)

NEWS.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# ggplot2 (development version)
22

3+
* Fixed bug in out-of-bounds binned breaks (@teunbrand, #6054)
4+
* Binned guides now accept expressions as labels (@teunbrand, #6005)
5+
* (internal) `Scale$get_labels()` format expressions as lists.
6+
* In non-orthogonal coordinate systems (`coord_sf()`, `coord_polar()` and
7+
`coord_radial()`), using 'AsIs' variables escape transformation when
8+
both `x` and `y` is an 'AsIs' variable (@teunbrand, #6205).
9+
* The following methods have been deprecated: `fortify.lm()`, `fortify.glht()`,
10+
`fortify.confint.glht()`, `fortify.summary.glht()` and `fortify.cld()`. It
11+
is recommend to use `broom::augment()` and `broom::tidy()` instead
12+
(@teunbrand, #3816).
13+
* Custom and raster annotation now respond to scale transformations, and can
14+
use AsIs variables for relative placement (@teunbrand based on
15+
@yutannihilation's prior work, #3120)
16+
* When discrete breaks have names, they'll be used as labels by default
17+
(@teunbrand, #6147).
18+
* The helper function `is.waiver()` is now exported to help extensions to work
19+
with `waiver()` objects (@arcresu, #6173).
20+
* Date(time) scales now throw appropriate errors when `date_breaks`,
21+
`date_minor_breaks` or `date_labels` are not strings (@RodDalBen, #5880)
22+
* `geom_errorbarh()` is deprecated in favour of
23+
`geom_errorbar(orientation = "y")` (@teunbrand, #5961).
24+
* `geom_contour()` should be able to recognise a rotated grid of points
25+
(@teunbrand, #4320)
26+
* `geom_boxplot()` gains additional arguments to style the colour, linetype and
27+
linewidths of the box, whiskers, median line and staples (@teunbrand, #5126)
28+
* (internal) Using `after_scale()` in the `Geom*$default_aes()` field is now
29+
evaluated in the context of data (@teunbrand, #6135)
30+
* Fixed bug where binned scales wouldn't simultaneously accept transformations
31+
and function-limits (@teunbrand, #6144).
332
* Fixed bug where the `ggplot2::`-prefix did not work with `stage()`
433
(@teunbrand, #6104).
534
* New `get_labs()` function for retrieving completed plot labels
@@ -184,6 +213,14 @@
184213
* The ellipsis argument is now checked in `fortify()`, `get_alt_text()`,
185214
`labs()` and several guides (@teunbrand, #3196).
186215
* `stat_summary_bin()` no longer ignores `width` parameter (@teunbrand, #4647).
216+
* Added `keep.zeroes` argument to `stat_bin()` (@teunbrand, #3449)
217+
* `coord_sf()` no longer errors when dealing with empty graticules (@teunbrand, #6052)
218+
* Added `theme_transparent()` with transparent backgrounds (@topepo).
219+
* New theme elements `palette.{aes}.discrete` and `palette.{aes}.continuous`.
220+
Theme palettes replace palettes in scales where `palette = NULL`, which is
221+
the new default in many scales (@teunbrand, #4696).
222+
* `guide_axis()` no longer reserves space for blank ticks
223+
(@teunbrand, #4722, #6069).
187224

188225
# ggplot2 3.5.1
189226

@@ -230,6 +267,7 @@ documentation updates.
230267
* `annotate()` now warns about `stat` or `position` arguments (@teunbrand, #5151)
231268
* `guide_coloursteps(even.steps = FALSE)` now works with discrete data that has
232269
been formatted by `cut()` (@teunbrand, #3877).
270+
* `ggsave()` now offers to install svglite if needed (@eliocamp, #6166).
233271

234272
# ggplot2 3.5.0
235273

R/annotation-custom.R

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,12 @@ GeomCustomAnn <- ggproto("GeomCustomAnn", Geom,
7070

7171
draw_panel = function(data, panel_params, coord, grob, xmin, xmax,
7272
ymin, ymax) {
73-
if (!inherits(coord, "CoordCartesian")) {
74-
cli::cli_abort("{.fn annotation_custom} only works with {.fn coord_cartesian}.")
75-
}
76-
corners <- data_frame0(
77-
x = c(xmin, xmax),
78-
y = c(ymin, ymax),
79-
.size = 2
73+
range <- ranges_annotation(
74+
coord, panel_params, xmin, xmax, ymin, ymax,
75+
fun = "annotation_custom"
8076
)
81-
data <- coord$transform(corners, panel_params)
82-
83-
x_rng <- range(data$x, na.rm = TRUE)
84-
y_rng <- range(data$y, na.rm = TRUE)
85-
86-
vp <- viewport(x = mean(x_rng), y = mean(y_rng),
87-
width = diff(x_rng), height = diff(y_rng),
77+
vp <- viewport(x = mean(range$x), y = mean(range$y),
78+
width = diff(range$x), height = diff(range$y),
8879
just = c("center","center"))
8980
editGrob(grob, vp = vp, name = paste(grob$name, annotation_id()))
9081
},
@@ -99,3 +90,21 @@ annotation_id <- local({
9990
i
10091
}
10192
})
93+
94+
ranges_annotation <- function(coord, panel_params, xmin, xmax, ymin, ymax, fun) {
95+
if (!inherits(coord, "CoordCartesian")) {
96+
cli::cli_abort("{.fn {fun}} only works with {.fn coord_cartesian}.")
97+
}
98+
data <- data_frame0(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax)
99+
data <- .ignore_data(data)[[1]]
100+
x <- panel_params$x$scale$transform_df(data)
101+
data[names(x)] <- x
102+
y <- panel_params$y$scale$transform_df(data)
103+
data[names(y)] <- y
104+
data <- .expose_data(data)[[1]]
105+
data <- coord$transform(data, panel_params)
106+
list(
107+
x = range(data$xmin, data$xmax, na.rm = TRUE),
108+
y = range(data$ymin, data$ymax, na.rm = TRUE)
109+
)
110+
}

R/annotation-raster.R

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,13 @@ GeomRasterAnn <- ggproto("GeomRasterAnn", Geom,
7373

7474
draw_panel = function(data, panel_params, coord, raster, xmin, xmax,
7575
ymin, ymax, interpolate = FALSE) {
76-
if (!inherits(coord, "CoordCartesian")) {
77-
cli::cli_abort("{.fn annotation_raster} only works with {.fn coord_cartesian}.")
78-
}
79-
corners <- data_frame0(
80-
x = c(xmin, xmax),
81-
y = c(ymin, ymax),
82-
.size = 2
76+
range <- ranges_annotation(
77+
coord, panel_params, xmin, xmax, ymin, ymax,
78+
fun = "annotation_raster"
79+
)
80+
rasterGrob(raster, range$x[1], range$y[1],
81+
diff(range$x), diff(range$y), default.units = "native",
82+
just = c("left","bottom"), interpolate = interpolate
8383
)
84-
data <- coord$transform(corners, panel_params)
85-
86-
x_rng <- range(data$x, na.rm = TRUE)
87-
y_rng <- range(data$y, na.rm = TRUE)
88-
89-
rasterGrob(raster, x_rng[1], y_rng[1],
90-
diff(x_rng), diff(y_rng), default.units = "native",
91-
just = c("left","bottom"), interpolate = interpolate)
9284
}
9385
)

R/axis-secondary.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ is.sec_axis <- function(x) {
129129
}
130130

131131
set_sec_axis <- function(sec.axis, scale) {
132-
if (!is.waive(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.")
@@ -182,11 +182,11 @@ 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.waive(scale$name)) self$name <- scale$name
185+
if (is.derived(self$name) && !is.waiver(scale$name)) self$name <- scale$name
186186
if (is.derived(self$breaks)) self$breaks <- scale$breaks
187-
if (is.waive(self$breaks)) {
187+
if (is.waiver(self$breaks)) {
188188
if (scale$is_discrete()) {
189-
self$breaks <- scale$get_breaks()
189+
self$breaks <- setNames(nm = scale$get_breaks())
190190
} else {
191191
breaks <- scale$get_transformation()$breaks
192192
n_breaks <- scale$n.breaks
@@ -235,7 +235,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
235235
self$mono_test(scale)
236236
breaks <- self$breaks
237237
} else {
238-
breaks <- scale$map(self$breaks)
238+
breaks <- setNames(scale$map(self$breaks), names(self$breaks))
239239
}
240240

241241
# Get scale's original range before transformation

R/backports.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ on_load({
6767
as.mask <- grid::as.mask
6868
}
6969
if ("linearGradient" %in% getNamespaceExports("grid")) {
70-
linearGradient <- grid::linearGradient()
70+
linearGradient <- grid::linearGradient
7171
}
7272
})

R/bin.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ bin_breaks <- function(breaks, closed = c("right", "left")) {
5454

5555
bin_breaks_width <- function(x_range, width = NULL, center = NULL,
5656
boundary = NULL, closed = c("right", "left")) {
57-
if (length(x_range) != 2) {
58-
cli::cli_abort("{.arg x_range} must have two elements.")
59-
}
57+
check_length(x_range, 2L)
6058

6159
# binwidth seems to be the argument name supplied to width. (stat-bin and stat-bindot)
6260
check_number_decimal(width, min = 0, allow_infinite = FALSE, arg = "binwidth")
@@ -106,9 +104,7 @@ bin_breaks_width <- function(x_range, width = NULL, center = NULL,
106104

107105
bin_breaks_bins <- function(x_range, bins = 30, center = NULL,
108106
boundary = NULL, closed = c("right", "left")) {
109-
if (length(x_range) != 2) {
110-
cli::cli_abort("{.arg x_range} must have two elements.")
111-
}
107+
check_length(x_range, 2L)
112108

113109
check_number_whole(bins, min = 1)
114110
if (zero_range(x_range)) {

0 commit comments

Comments
 (0)