Skip to content

Commit ec1c99b

Browse files
committed
Merge branch 'main' into Yunuuuu-main
2 parents bba1d9a + 6906324 commit ec1c99b

40 files changed

+166
-104
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,21 @@ jobs:
5858
http-user-agent: ${{ matrix.config.http-user-agent }}
5959
use-public-rspm: true
6060

61+
# TODO: remove this when R 4.6 is released
62+
- name: Tweak for old Windows (R 4.1)
63+
uses: r-lib/actions/setup-r-dependencies@v2
64+
if: ${{ matrix.config.os == 'windows-latest' && matrix.config.r == 'oldrel-4' }}
65+
with:
66+
cache-version: 3
67+
extra-packages: >
68+
any::rcmdcheck,
69+
70+
Hmisc=?ignore-before-r=4.2.0,
71+
quantreg=?ignore-before-r=4.3.0
72+
needs: check
73+
6174
- uses: r-lib/actions/setup-r-dependencies@v2
75+
if: ${{ matrix.config.os != 'windows-latest' || matrix.config.r != 'oldrel-4' }}
6276
with:
6377
cache-version: 3
6478
extra-packages: >

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: ggplot2
22
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
3-
Version: 3.5.2.9002
3+
Version: 4.0.0.9000
44
Authors@R: c(
55
person("Hadley", "Wickham", , "[email protected]", role = "aut",
66
comment = c(ORCID = "0000-0003-4757-117X")),
@@ -52,6 +52,7 @@ Suggests:
5252
ggplot2movies,
5353
hexbin,
5454
Hmisc,
55+
hms,
5556
knitr,
5657
mapproj,
5758
maps,
@@ -83,7 +84,7 @@ Config/usethis/last-upkeep: 2025-04-23
8384
Encoding: UTF-8
8485
LazyData: true
8586
Roxygen: list(markdown = TRUE)
86-
RoxygenNote: 7.3.2
87+
RoxygenNote: 7.3.3
8788
Collate:
8889
'ggproto.R'
8990
'ggplot-global.R'

NEWS.md

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

3+
### Bug fixes
4+
5+
* Fixed regression where `draw_key_rect()` stopped using `fill` colours
6+
(@mitchelloharawild, #6609).
7+
* Fixed regression where `scale_{x,y}_*()` threw an error when an expression
8+
object is set to `labels` argument (@yutannihilation, #6617).
9+
10+
11+
* Allow `stat` in `geom_hline`, `geom_vline`, and `geom_abline`. (@sierrajohnson, #6559)
12+
13+
# ggplot2 4.0.0
14+
315
## User facing
416

517
### Breaking changes

R/backports.R

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
1-
# Backport fix from R 3.3:
2-
# https://github.com/wch/r-source/commit/4efc81c98d262f93de9e7911aaa910f5c63cd00f
3-
if (getRversion() < "3.3") {
4-
absolute.units <- utils::getFromNamespace("absolute.units", "grid")
5-
absolute.units.unit <- utils::getFromNamespace("absolute.units.unit", "grid")
6-
absolute.units.unit.list <- utils::getFromNamespace("absolute.units.unit.list", "grid")
7-
absolute.units.unit.arithmetic <- utils::getFromNamespace("absolute.units.unit.arithmetic", "grid")
8-
9-
backport_unit_methods <- function() {
10-
registerS3method("absolute.units", "unit", absolute.units.unit)
11-
registerS3method("absolute.units", "unit.list", absolute.units.unit.list)
12-
registerS3method("absolute.units", "unit.arithmetic", absolute.units.unit.arithmetic)
13-
}
14-
} else {
15-
backport_unit_methods <- function() {}
16-
}
17-
181
# enable usage of <S7_object>@name in package code
192
#' @rawNamespace if (getRversion() < "4.3.0") importFrom("S7", "@")
203
NULL
214

22-
on_load(backport_unit_methods())
23-
245
unitType <- function(x) {
256
unit <- attr(x, "unit")
267
if (!is.null(unit)) {

R/geom-abline.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ NULL
6969
#' geom_hline(aes(yintercept = wt, colour = wt), mean_wt) +
7070
#' facet_wrap(~ cyl)
7171
geom_abline <- function(mapping = NULL, data = NULL,
72+
stat = "identity",
7273
...,
7374
slope,
7475
intercept,
7576
na.rm = FALSE,
76-
show.legend = NA) {
77+
show.legend = NA,
78+
inherit.aes = FALSE) {
7779

7880
# If nothing set, default to y = x
7981
if (is.null(mapping) && missing(slope) && missing(intercept)) {
@@ -108,11 +110,11 @@ geom_abline <- function(mapping = NULL, data = NULL,
108110
layer(
109111
data = data,
110112
mapping = mapping,
111-
stat = StatIdentity,
113+
stat = stat,
112114
geom = GeomAbline,
113115
position = PositionIdentity,
114116
show.legend = show.legend,
115-
inherit.aes = FALSE,
117+
inherit.aes = inherit.aes,
116118
params = list2(
117119
na.rm = na.rm,
118120
...

R/geom-count.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ NULL
33

44
#' Count overlapping points
55
#'
6-
#' This is a variant [geom_point()] that counts the number of
6+
#' This is a variant of [geom_point()] that counts the number of
77
#' observations at each location, then maps the count to point area. It
88
#' useful when you have discrete data and overplotting.
99
#'

R/geom-hline.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ NULL
44
#' @export
55
#' @rdname geom_abline
66
geom_hline <- function(mapping = NULL, data = NULL,
7-
position = "identity",
7+
stat = "identity", position = "identity",
88
...,
99
yintercept,
1010
na.rm = FALSE,
11-
show.legend = NA) {
11+
show.legend = NA,
12+
inherit.aes = FALSE) {
1213

1314
# Act like an annotation
1415
if (!missing(yintercept)) {
@@ -28,11 +29,11 @@ geom_hline <- function(mapping = NULL, data = NULL,
2829
layer(
2930
data = data,
3031
mapping = mapping,
31-
stat = StatIdentity,
32+
stat = stat,
3233
geom = GeomHline,
3334
position = position,
3435
show.legend = show.legend,
35-
inherit.aes = FALSE,
36+
inherit.aes = inherit.aes,
3637
params = list2(
3738
na.rm = na.rm,
3839
...

R/geom-polygon.R

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ GeomPolygon <- ggproto("GeomPolygon", Geom,
4141
)
4242
)
4343
} else {
44-
if (getRversion() < "3.6") {
45-
cli::cli_abort("Polygons with holes requires R 3.6 or above.")
46-
}
4744
# Sort by group to make sure that colors, fill, etc. come in same order
4845
munched <- munched[order(munched$group, munched$subgroup), ]
4946
id <- match(munched$subgroup, unique0(munched$subgroup))
@@ -177,16 +174,3 @@ GeomPolygon <- ggproto("GeomPolygon", Geom,
177174
#' p
178175
#' }
179176
geom_polygon <- make_constructor(GeomPolygon)
180-
181-
# Assigning pathGrob in .onLoad ensures that packages that subclass GeomPolygon
182-
# do not install with error `possible error in 'pathGrob(munched$x, munched$y, ':
183-
# unused argument (pathId = munched$group)` despite the fact that this is correct
184-
# usage
185-
pathGrob <- NULL
186-
on_load(
187-
if (getRversion() < as.numeric_version("3.6")) {
188-
pathGrob <- function(..., pathId.lengths) {
189-
grid::pathGrob(...)
190-
}
191-
}
192-
)

R/geom-vline.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ NULL
44
#' @export
55
#' @rdname geom_abline
66
geom_vline <- function(mapping = NULL, data = NULL,
7-
position = "identity",
7+
stat = "identity", position = "identity",
88
...,
99
xintercept,
1010
na.rm = FALSE,
11-
show.legend = NA) {
11+
show.legend = NA,
12+
inherit.aes = FALSE) {
1213

1314
# Act like an annotation
1415
if (!missing(xintercept)) {
@@ -28,11 +29,11 @@ geom_vline <- function(mapping = NULL, data = NULL,
2829
layer(
2930
data = data,
3031
mapping = mapping,
31-
stat = StatIdentity,
32+
stat = stat,
3233
geom = GeomVline,
3334
position = position,
3435
show.legend = show.legend,
35-
inherit.aes = FALSE,
36+
inherit.aes = inherit.aes,
3637
params = list2(
3738
na.rm = na.rm,
3839
...

R/guides-.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ Guides <- ggproto(
659659
if (!stretch_spacing) {
660660
spacing <- convertWidth(spacing, "cm")
661661
}
662-
heights <- unit(height_cm(lapply(heights, sum)), "cm")
662+
663+
total_height <- max(inject(unit.c(!!!lapply(heights, sum))))
663664

664665
if (stretch_x || stretch_spacing) {
665666
widths <- redistribute_null_units(widths, spacing, margin, "width")
@@ -672,14 +673,14 @@ Guides <- ggproto(
672673
# Set global justification
673674
vp <- viewport(
674675
x = global_xjust, y = global_yjust, just = global_just,
675-
height = max(heights),
676+
height = total_height,
676677
width = vp_width
677678
)
678679

679680
# Initialise gtable as legends in a row
680681
guides <- gtable_row(
681682
name = "guides", grobs = grobs,
682-
widths = widths, height = max(heights),
683+
widths = widths, height = total_height,
683684
vp = vp
684685
)
685686

@@ -701,7 +702,7 @@ Guides <- ggproto(
701702
if (!stretch_spacing) {
702703
spacing <- convertWidth(spacing, "cm")
703704
}
704-
widths <- unit(width_cm(lapply(widths, sum)), "cm")
705+
total_width <- max(inject(unit.c(!!!lapply(widths, sum))))
705706

706707
if (stretch_y || stretch_spacing) {
707708
heights <- redistribute_null_units(heights, spacing, margin, "height")
@@ -715,13 +716,13 @@ Guides <- ggproto(
715716
vp <- viewport(
716717
x = global_xjust, y = global_yjust, just = global_just,
717718
height = vp_height,
718-
width = max(widths)
719+
width = total_width
719720
)
720721

721722
# Initialise gtable as legends in a column
722723
guides <- gtable_col(
723724
name = "guides", grobs = grobs,
724-
width = max(widths), heights = heights,
725+
width = total_width, heights = heights,
725726
vp = vp
726727
)
727728

0 commit comments

Comments
 (0)