Skip to content

Commit 271e31a

Browse files
committed
Clarified needed input to stat_contour
Fixes #1577
1 parent f70b4f6 commit 271e31a

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ggplot2 2.1.0.9000
22

3+
* Clarified needed input to `geom_contour()` (#1577).
4+
35
* Import tibble. This ensures that all built-in datasets print compactly
46
even if you haven't explicitly loaded tibble or dplyr (#1677).
57

R/geom-contour.r

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#' Display contours of a 3d surface in 2d.
22
#'
3+
#' To be a valid surface, the most only be a single combination of each
4+
#' unique \code{x} and \code{y} aesthetics. Contouring tends to work best
5+
#' when \code{x} and \code{y} form a (roughly) evenly spaced grid.
6+
#'
37
#' @section Aesthetics:
48
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "contour")}
59
#'

R/stat-contour.r

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ StatContour <- ggproto("StatContour", Stat,
6666
contour_lines <- function(data, breaks, complete = FALSE) {
6767
z <- tapply(data$z, data[c("x", "y")], identity)
6868

69+
if (is.list(z)) {
70+
stop("Contour requires single `z` at each combination of `x` and `y`.",
71+
call. = FALSE)
72+
}
73+
6974
cl <- grDevices::contourLines(
7075
x = sort(unique(data$x)), y = sort(unique(data$y)), z = z,
7176
levels = breaks)

man/geom_contour.Rd

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

0 commit comments

Comments
 (0)