Skip to content

Respect the presence of holes in calculated contours - #3705

Merged
thomasp85 merged 2 commits into
v3.3.0-rcfrom
contour-holes
Jan 8, 2020
Merged

thomasp85 merged 2 commits into
v3.3.0-rcfrom
contour-holes

Conversation

@thomasp85

Copy link
Copy Markdown
Member

The current implementation of stat_contour_filled() does not respect the presence of holes in the contour as it does not provide a subgroup column. This PR fixes this:

Before:

library(ggplot2)

volcano_long <- data.frame(
  x = as.vector(col(volcano)),
  y = as.vector(row(volcano)),
  z = as.vector(volcano)
)

ggplot(volcano_long, aes(x, y, z = z)) + 
  geom_contour_filled(aes(fill = stat(level)), bins = 8) + 
  scale_fill_brewer()

Created on 2020-01-08 by the reprex package (v0.3.0)

After:

library(ggplot2)

volcano_long <- data.frame(
  x = as.vector(col(volcano)),
  y = as.vector(row(volcano)),
  z = as.vector(volcano)
)

ggplot(volcano_long, aes(x, y, z = z)) + 
  geom_contour_filled(aes(fill = stat(level)), bins = 8) + 
  scale_fill_brewer()

Created on 2020-01-08 by the reprex package (v0.3.0)

This PR also makes sure that fill can be partly transparent without building up opacity since contained levels are cut out

@thomasp85 thomasp85 added this to the ggplot2 3.3.0 milestone Jan 8, 2020
@thomasp85
thomasp85 requested a review from clauswilke January 8, 2020 11:14

@clauswilke clauswilke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@thomasp85
thomasp85 merged commit a48fb5b into v3.3.0-rc Jan 8, 2020
@thomasp85
thomasp85 deleted the contour-holes branch October 6, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants