Skip to content

Commit 0f801fc

Browse files
authored
Merge pull request #29 from tidyverse/master
Sync Fork from Upstream Repo
2 parents 82ff244 + dbd7d79 commit 0f801fc

File tree

11 files changed

+75
-34
lines changed

11 files changed

+75
-34
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
if: runner.os == 'macOS'
7979
run: |
8080
# XQuartz is needed by vdiffr
81-
brew cask install xquartz
81+
brew install xquartz
8282
8383
# Use only binary packages
8484
echo 'options(pkgType = "binary")' >> ~/.Rprofile

.github/workflows/test-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Install system dependencies on macOS
4242
run: |
4343
# XQuartz is needed by vdiffr
44-
brew cask install xquartz
44+
brew install xquartz
4545
4646
- name: Install dependencies
4747
run: |

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Suggests:
4646
ggplot2movies,
4747
hexbin,
4848
Hmisc,
49+
interp,
4950
knitr,
5051
lattice,
5152
mapproj,

R/geom-contour.r

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#' 2D contours of a 3D surface
22
#'
33
#' ggplot2 can not draw true 3D surfaces, but you can use `geom_contour()`,
4-
#' `geom_contour_filled()`, and [geom_tile()] to visualise 3D surfaces in 2D.
5-
#' To specify a valid surface, the data must contain `x`, `y`, and `z` coordinates,
6-
#' and each unique combination of `x` and `y` can appear exactly once. Contouring
7-
#' tends to work best when `x` and `y` form a (roughly) evenly
8-
#' spaced grid. If your data is not evenly spaced, you may want to interpolate
9-
#' to a grid before visualising, see [geom_density_2d()].
4+
#' `geom_contour_filled()`, and [geom_tile()] to visualise 3D surfaces in 2D. To
5+
#' specify a valid surface, the data must contain `x`, `y`, and `z` coordinates,
6+
#' and each unique combination of `x` and `y` can appear at most once.
7+
#' Contouring requires that the points can be rearranged so that the `z` values
8+
#' form a matrix, with rows corresponding to unique `x` values, and columns
9+
#' corresponding to unique `y` values. Missing entries are allowed, but contouring
10+
#' will only be done on cells of the grid with all four `z` values present. If
11+
#' your data is irregular, you can interpolate to a grid before visualising
12+
#' using the [interp::interp()] function from the `interp` package
13+
#' (or one of the interpolating functions from the `akima` package.)
1014
#'
1115
#' @eval rd_aesthetics("geom", "contour")
1216
#' @eval rd_aesthetics("geom", "contour_filled")
@@ -15,9 +19,9 @@
1519
#' @inheritParams geom_path
1620
#' @param bins Number of contour bins. Overridden by `binwidth`.
1721
#' @param binwidth The width of the contour bins. Overridden by `breaks`.
18-
#' @param breaks Numeric vector to set the contour breaks.
19-
#' Overrides `binwidth` and `bins`. By default, this is a vector of
20-
#' length ten with [pretty()] breaks.
22+
#' @param breaks Numeric vector to set the contour breaks. Overrides `binwidth`
23+
#' and `bins`. By default, this is a vector of length ten with [pretty()]
24+
#' breaks.
2125
#' @seealso [geom_density_2d()]: 2d density contours
2226
#' @export
2327
#' @examples
@@ -47,6 +51,22 @@
4751
#' v + geom_contour(colour = "red")
4852
#' v + geom_raster(aes(fill = density)) +
4953
#' geom_contour(colour = "white")
54+
#'
55+
#' # Irregular data
56+
#' if (requireNamespace("interp")) {
57+
#' # Use a dataset from the interp package
58+
#' data(franke, package = "interp")
59+
#' origdata <- as.data.frame(interp::franke.data(1, 1, franke))
60+
#' grid <- with(origdata, interp::interp(x, y, z))
61+
#' griddf <- subset(data.frame(x = rep(grid$x, nrow(grid$z)),
62+
#' y = rep(grid$y, each = ncol(grid$z)),
63+
#' z = as.numeric(grid$z)),
64+
#' !is.na(z))
65+
#' ggplot(griddf, aes(x, y, z = z)) +
66+
#' geom_contour_filled() +
67+
#' geom_point(data = origdata)
68+
#' } else
69+
#' message("Irregular data requires the 'interp' package")
5070
#' }
5171
geom_contour <- function(mapping = NULL, data = NULL,
5272
stat = "contour", position = "identity",

R/position-jitterdodge.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#' @inheritParams position_jitter
1414
#' @export
1515
#' @examples
16-
#' dsub <- diamonds[ sample(nrow(diamonds), 1000), ]
16+
#' dsub <- diamonds[sample(nrow(diamonds), 1000), ]
1717
#' ggplot(dsub, aes(x = cut, y = carat, fill = clarity)) +
1818
#' geom_boxplot(outlier.size = 0) +
1919
#' geom_point(pch = 21, position = position_jitterdodge())

man/geom_contour.Rd

Lines changed: 29 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_density_2d.Rd

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

man/position_jitterdodge.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/figs/coord-sf/sf-polygons.svg

Lines changed: 4 additions & 4 deletions
Loading

tests/figs/deps.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
- vdiffr-svg-engine: 1.0
2-
- vdiffr: 0.3.1
2+
- vdiffr: 0.3.3
33
- freetypeharfbuzz: 0.2.5

0 commit comments

Comments
 (0)