Closed henryli78 closed 5 years ago
With this one, geom_smooth
is trying to apply a smoother to the colors. This isn't going to work, though. When you write ggplot(data=mpg) + aes(x='displ', y='hwy', color = 'class') + ...
, it is applying an aesthetic globally to the plot. Instead, you want geom_point and geom_smooth to each use different aesthetics. You can do this by removing the global aes
and instead proving an aesthetic to each individually using the mapping
keyword argument. For example, ... + geom_point(mapping=aes(x='displ', y='hwy', color = 'class')) + ...
I'm trying to understand plotnine's way of grouping and coloring points. I'm able to replicate Q14's intended diagram up to the legend, where whenever I try to add
color = 'class'
I get the errorAny ideas? My exact code is:
(plotnine.ggplot(data = mpg, mapping = plotnine.aes(x = 'displ', y = 'hwy', color = 'class'))
+ plotnine.geoms.geom_point()
+ plotnine.geom_smooth(method = 'loess'))