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

linetype = NA should imply no line, not errors #6269

Open
teunbrand opened this issue Jan 6, 2025 · 0 comments · May be fixed by #6270
Open

linetype = NA should imply no line, not errors #6269

teunbrand opened this issue Jan 6, 2025 · 0 comments · May be fixed by #6270
Labels
bug an unexpected problem or unintended behavior

Comments

@teunbrand
Copy link
Collaborator

When using it with lines, the observations get flagged as missing and get removed.

library(ggplot2)

p <- ggplot(data.frame(x = 1:2, y = 1:2), aes(x, y))
p + geom_line(linetype = NA)
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_line()`).

However, if we don't throw away such observations, we invite errors from grid.

p + geom_tile(linetype = NA)
#> Error in grid.Call.graphics(C_rect, x$x, x$y, x$width, x$height, resolveHJust(x$just, : invalid line type

Created on 2025-01-06 with reprex v2.1.1

This can be painful when using scales, as in #6097 we've changed scale_linetype()$na.value to NA.
My suggestion for non-line geometries is to translate these NAs to "blank" or 0, depending on the type.

@teunbrand teunbrand linked a pull request Jan 6, 2025 that will close this issue
@teunbrand teunbrand added the bug an unexpected problem or unintended behavior label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant