Skip to content

Commit 9590b7f

Browse files
authored
Merge branch 'master' into issue-3090-warn-data-hline-vline-abline
2 parents 47fc905 + 8371417 commit 9590b7f

File tree

11 files changed

+97
-14
lines changed

11 files changed

+97
-14
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ quickly as possible. The guide is divided into two main pieces:
66
1. Filing a bug report or feature request in an issue.
77
1. Suggesting a change via a pull request.
88

9-
Please note that ggplot2 is released with a [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). By contributing to this project,
9+
Please note that ggplot2 is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project,
1010
you agree to abide by its terms.
1111

1212
## Issues

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: ggplot2
2-
Version: 3.1.1.9000
2+
Version: 3.2.0.9000
33
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
44
Description: A system for 'declaratively' creating graphics,
55
based on "The Grammar of Graphics". You provide the data, tell 'ggplot2'

NEWS.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# ggplot2 3.2.0.9000
2-
3-
## Minor improvements and bug fixes
1+
# ggplot2 (development version)
42

53
* `geom_abline()`, `geom_hline()`, and `geom_vline()` now issue
64
more informative warnings when supplied with set aesthetics
@@ -16,6 +14,21 @@ extension developers if they have relied on internals that have been changed.
1614
This release also sees the addition of Hiroaki Yutani (@yutannihilation) to the
1715
core developer team.
1816

17+
## Breaking changes
18+
19+
* Two patches (#2996 and #3050) fixed minor rendering problems. In most cases,
20+
the visual changes are so subtle that they are difficult to see with the naked
21+
eye. However, these changes are detected by the vdiffr package, and therefore
22+
any package developers who use vdiffr to test for visual correctness of ggplot2
23+
plots will have to regenerate all reference images.
24+
25+
* In some cases, ggplot2 now produces a warning or an error for code that previously
26+
produced plot output. In all these cases, the previous plot output was accidental,
27+
and the plotting code uses the ggplot2 API in a way that would lead to undefined
28+
behavior. Examples include a missing `group` aesthetic in `geom_boxplot()` (#3316),
29+
annotations across multiple facets (#3305), and not using aesthetic mappings when
30+
drawing ribbons with `geom_ribbon()` (#3318).
31+
1932
## New features
2033

2134
* This release includes a range of internal changes that speeds up plot

R/annotation.r

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,22 @@ annotate <- function(geom, x = NULL, y = NULL, xmin = NULL, xmax = NULL,
4646

4747
# Check that all aesthetic have compatible lengths
4848
lengths <- vapply(aesthetics, length, integer(1))
49-
unequal <- length(unique(setdiff(lengths, 1L))) > 1L
50-
if (unequal) {
49+
n <- unique(lengths)
50+
51+
# if there is more than one unique length, ignore constants
52+
if (length(n) > 1L) {
53+
n <- setdiff(n, 1L)
54+
}
55+
56+
# if there is still more than one unique length, we error out
57+
if (length(n) > 1L) {
5158
bad <- lengths != 1L
5259
details <- paste(names(aesthetics)[bad], " (", lengths[bad], ")",
5360
sep = "", collapse = ", ")
5461
stop("Unequal parameter lengths: ", details, call. = FALSE)
5562
}
5663

57-
data <- new_data_frame(position, n = max(lengths))
64+
data <- new_data_frame(position, n = n)
5865
layer(
5966
geom = geom,
6067
params = list(

R/geom-boxplot.r

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ geom_boxplot <- function(mapping = NULL, data = NULL,
159159
#' @export
160160
GeomBoxplot <- ggproto("GeomBoxplot", Geom,
161161

162-
# need to declare `width`` here in case this geom is used with a stat that
162+
# need to declare `width` here in case this geom is used with a stat that
163163
# doesn't have a `width` parameter (e.g., `stat_identity`).
164164
extra_params = c("na.rm", "width"),
165165

@@ -200,6 +200,14 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom,
200200
outlier.alpha = NULL,
201201
notch = FALSE, notchwidth = 0.5, varwidth = FALSE) {
202202

203+
# this may occur when using geom_boxplot(stat = "identity")
204+
if (nrow(data) != 1) {
205+
stop(
206+
"Can't draw more than one boxplot per group. Did you forget aes(group = ...)?",
207+
call. = FALSE
208+
)
209+
}
210+
203211
common <- list(
204212
colour = data$colour,
205213
size = data$size,

R/performance.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ new_data_frame <- function(x = list(), n = NULL) {
44
if (length(x) != 0 && is.null(names(x))) stop("Elements must be named", call. = FALSE)
55
lengths <- vapply(x, length, integer(1))
66
if (is.null(n)) {
7-
n <- if (length(x) == 0) 0 else max(lengths)
7+
n <- if (length(x) == 0 || min(lengths) == 0) 0 else max(lengths)
88
}
99
for (i in seq_along(x)) {
1010
if (lengths[i] == n) next
@@ -32,7 +32,7 @@ split_matrix <- function(x, col_names = colnames(x)) {
3232
if (!is.null(col_names)) names(x) <- col_names
3333
x
3434
}
35-
35+
3636
mat_2_df <- function(x, col_names = colnames(x)) {
3737
new_data_frame(split_matrix(x, col_names))
3838
}

R/stat-smooth.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#' @param method Smoothing method (function) to use, accepts either a character vector,
22
#' e.g. `"auto"`, `"lm"`, `"glm"`, `"gam"`, `"loess"` or a function, e.g.
3-
#' `MASS::rlm` or `mgcv::gam`, `base::lm`, or `base::loess`.
3+
#' `MASS::rlm` or `mgcv::gam`, `stats::lm`, or `stats::loess`.
44
#'
55
#' For `method = "auto"` the smoothing method is chosen based on the
6-
#' size of the largest group (across all panels). [loess()] is
6+
#' size of the largest group (across all panels). [stats::loess()] is
77
#' used for less than 1,000 observations; otherwise [mgcv::gam()] is
88
#' used with `formula = y ~ s(x, bs = "cs")`. Somewhat anecdotally,
99
#' `loess` gives a better appearance, but is \eqn{O(N^{2})}{O(N^2)} in memory,

R/zzz.r

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,21 @@
1616
})
1717
}
1818

19+
# Assigning pathGrob in .onLoad ensures that packages that subclass GeomPolygon
20+
# do not install with error `possible error in 'pathGrob(munched$x, munched$y, ':
21+
# unused argument (pathId = munched$group)` despite the fact that this is correct
22+
# usage
23+
pathGrob <- NULL
24+
1925
.onLoad <- function(...) {
2026
backport_unit_methods()
2127

28+
if (getRversion() < as.numeric_version("3.6")) {
29+
pathGrob <<- function(..., pathId.lengths) {
30+
grid::pathGrob(...)
31+
}
32+
}
33+
2234
.zeroGrob <<- grob(cl = "zeroGrob", name = "NULL")
2335

2436
ggplot_global$theme_current <- theme_gray()

man/geom_smooth.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-geom-boxplot.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ test_that("boxes with variable widths do not overlap", {
4747
expect_false(any(duplicated(xid)))
4848
})
4949

50+
test_that("boxplots with a group size >1 error", {
51+
p <- ggplot(
52+
data_frame(x = "one value", y = 3, value = 4:6),
53+
aes(x, ymin = 0, lower = 1, middle = y, upper = value, ymax = 10)
54+
) +
55+
geom_boxplot(stat = "identity")
56+
57+
expect_equal(nrow(layer_data(p, 1)), 3)
58+
expect_error(layer_grob(p, 1), "Can't draw more than one boxplot")
59+
})
5060

5161
# Visual tests ------------------------------------------------------------
5262

0 commit comments

Comments
 (0)