Skip to content

Conversation

@teunbrand
Copy link
Collaborator

This is a spontaneous PR without a linked issue.

The current error message when using incompatible palette and na.value is confusing. It is unclear why na.value should have the character type.

library(ggplot2)

df <- mpg
df$drv[12] <- NA

ggplot(df, aes(displ, hwy, shape = drv)) +
  geom_point() +
  scale_shape_manual(
    values = c("circle small", "triangle", "square"),
    na.value = 4
  )
#> Error in `vec_slice<-`:
#> ! Can't convert `na_value` <double> to <character>.

Created on 2025-12-08 with reprex v2.1.1

In this PR, it is more clear (it should match the palette type).

#> Error in `vec_assign()` at ggplot2/R/scale-.R:1343:7:
#> ! Can't convert `na.value` <double> to match type of `palette` <character>.

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.

1 participant