Drawing isolines and isobands with 'ggplot2'
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R separate out ggplot2 specific code Jan 25, 2019
man update readme Jan 25, 2019
tests separate out ggplot2 specific code Jan 25, 2019
.Rbuildignore fix build Jan 21, 2019
.gitignore initial import Dec 29, 2018
.travis.yml set up travis for sf Jan 22, 2019
DESCRIPTION clean gpl2 for ggplot2 specific code Jan 25, 2019
LICENSE clean gpl2 for ggplot2 specific code Jan 25, 2019
NAMESPACE separate out ggplot2 specific code Jan 25, 2019
README.Rmd fix typo Jan 25, 2019
README.md fix typo Jan 25, 2019
ggisoband.Rproj separate out ggplot2 specific code Jan 25, 2019

README.md

ggisoband

This package provides a ggplot2 interface to the isoband library which can generate contour lines (isolines) and contour polygons (isobands) from regularly spaced grids containing elevation data.

Installation

Install from github with:

devtools::install_github("clauswilke/ggisoband")

Examples

We can draw contour lines and contour bands, including partially transparent contour bands.

library(ggplot2)
library(ggisoband)

volcano3d <- reshape2::melt(volcano)
names(volcano3d) <- c("x", "y", "z")

ggplot(volcano3d, aes(x, y, z = z)) +
  geom_isobands(aes(color = stat(zmin)), fill = NA) +
  scale_color_viridis_c() +
  coord_cartesian(expand = FALSE) +
  theme_bw()

ggplot(volcano3d, aes(x, y, z = z)) +
  geom_isobands(aes(fill = stat(zmin)), color = NA) +
  scale_fill_viridis_c(guide = "legend") +
  coord_cartesian(expand = FALSE) +
  theme_bw()

# set polygon_outline = FALSE when drawing filled polygons
# with alpha transparency
ggplot(volcano3d, aes(x, y, z = z)) +
  geom_isobands(
    aes(fill = stat(zmin)), color = NA,
    alpha = 0.5, polygon_outline = FALSE
  ) +
  scale_fill_viridis_c(guide = "legend") +
  coord_cartesian(expand = FALSE) +
  theme_bw()

We can also draw contour bands derived from a 2D density estimation.

ggplot(faithful, aes(eruptions, waiting)) +
  geom_density_bands(aes(fill = stat(density)), color = "gray40", alpha = 0.7, size = 0.2) +
  geom_point(shape = 21, fill = "white") +
  scale_fill_viridis_c(guide = "legend")