Skip to content
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

ERROR thrown when trying to draw key for missing pattern #107

Closed
Tracked by #104
davidhodge931 opened this issue Jan 14, 2024 · 4 comments · Fixed by #117
Closed
Tracked by #104

ERROR thrown when trying to draw key for missing pattern #107

davidhodge931 opened this issue Jan 14, 2024 · 4 comments · Fixed by #117
Assignees
Labels
enhancement New feature or request

Comments

@davidhodge931
Copy link

library(ggplot2)
library(ggpattern)

df <- data.frame(x = c(1, 2, 3), y = c(1, 2, NA), fill = c("A", "B", NA))

ggplot(df, aes(x, y, fill = fill, pattern = fill)) +
  geom_col_pattern(position = 'identity')
#> Warning: The `scale_name` argument of `discrete_scale()` is deprecated as of ggplot2
#> 3.5.0.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_col_pattern()`).
#> Error in if (pat == "regular_polygon" && is.numeric(params$pattern_shape)) params$pattern_shape <- "convex6": missing value where TRUE/FALSE needed

Created on 2024-01-15 with reprex v2.1.0

@davidhodge931 davidhodge931 changed the title [BUG] ggpattern doesn't seem to work with DEV ggplot2 ggpattern doesn't seem to work with DEV ggplot2 Jan 14, 2024
@trevorld trevorld changed the title ggpattern doesn't seem to work with DEV ggplot2 ggpattern throws ERROR when trying to draw key of NA pattern Jan 15, 2024
@trevorld
Copy link
Owner

ggpattern doesn't seem to work with DEV ggplot2

Are you sure this is an issue with the release/development version of {ggplot2}?

The issue to me seems to arise when trying to draw a legend for an NA pattern (instead of the "none" pattern) which {ggpattern} doesn't seem to be able to handle.

@trevorld trevorld changed the title ggpattern throws ERROR when trying to draw key of NA pattern ERROR raised when trying to draw key of NA pattern Jan 15, 2024
@trevorld trevorld changed the title ERROR raised when trying to draw key of NA pattern ERROR thrown when trying to draw key for missing pattern Jan 15, 2024
@trevorld
Copy link
Owner

  • The ERROR message could certainly be made more intuitive
  • Not immediately obvious to me that throwing an ERROR in this situation is unreasonable

@davidhodge931
Copy link
Author

I initially raised this issue on ggplot2, and the authors there suggested a fix might be to set a default na value

tidyverse/ggplot2#5608

@trevorld
Copy link
Owner

trevorld commented Jan 16, 2024

the authors there suggested a fix might be to set a default na value

I'll look into setting a default na.value = "none" for scale_pattern_discrete()

@trevorld trevorld self-assigned this Jan 16, 2024
@trevorld trevorld added the enhancement New feature or request label Jan 16, 2024
@trevorld trevorld mentioned this issue Jan 16, 2024
23 tasks
trevorld added a commit that referenced this issue Apr 22, 2024
* The default `na.value` for `scale_pattern_continuous()`, `scale_pattern_discrete()`, and `scale_pattern_manual()` is now "none" (#107).

closes #107
trevorld added a commit that referenced this issue Apr 23, 2024
* The default `na.value` for `scale_pattern_continuous()`, `scale_pattern_discrete()`, and `scale_pattern_manual()` is now "none" (#107).

closes #107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants