plotnine icon indicating copy to clipboard operation
plotnine copied to clipboard

Fail when a discrete scale receives unused arguments

Open machow opened this issue 1 year ago • 1 comments

Currently, if you mistakenly use a scale_*_discrete() instead of scale_*_manual(), it works but nothing happens. This can be a bit tricky to debug.

from ggplot.data import penguins

p = ggplot(penguins, aes("bill_length_mm", "bill_depth_mm")) + geom_point(
    aes(shape="species", color="species"), size=3
)

p
p + scale_shape_discrete(breaks=["Adelie", "Chinstrap", "Gentoo"], values=["s", "o", "^"])

I noticed that ggplot2 raises a handy error:

> p + scale_shape_discrete(breaks=c("Adelie", "Chinstrap", "Gentoo"), values=c("1", "2", "3"))
Error in discrete_scale("shape", name = name, palette = pal_shape(solid),  : 
  unused argument (values = c("1", "2", "3"))

machow avatar Jun 13 '24 16:06 machow