Skip to content

Issue with geom_contour_filled when the z values are too close together #4874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Jun 13, 2022 · 0 comments · Fixed by #4888
Closed

Issue with geom_contour_filled when the z values are too close together #4874

ghost opened this issue Jun 13, 2022 · 0 comments · Fixed by #4888

Comments

@ghost
Copy link

ghost commented Jun 13, 2022

There seems to be a bug in the function geom_contour_filled where it fails in some simple cases.

library(tidyverse)

#Generate some data
data = crossing(x = 1:10, y = 1:10) %>% 
  mutate(z = (x+y)/4)

#Works great
ggplot(data) + geom_contour_filled(aes(x, y, z = z))

#Make a minor tweak and it fails
data2 = data %>% mutate(z = z + 100)
ggplot(data2) + geom_contour_filled(aes(x, y, z = z))
#> Warning: Computation failed in `stat_contour_filled()`:
#> factor level [4] is duplicated

Looking into it, I believe the problem is with the legend names (more specifically the function pretty_isoband_levels). If the z values are close, you can get different levels with the same names because it only uses 3 digits (eg. "(101, 101]" and again "(101, 101]").

Created on 2022-06-14 by the reprex package (v2.0.1)

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 a pull request may close this issue.

0 participants