How can one merge the color and shape in the legend of plotnine? It seems to be possible in R. But I can't get it to work in plotnine...
Here is one example:
from plotnine import ggplot, geom_point, aes, stat_smooth, facet_wrap
from plotnine.data import mtcars
(
ggplot(mtcars, aes('cyl', 'mpg', color='factor(gear)', shape='factor(vs)'))
+ geom_jitter()
)
this creates the following graph:
I wanted to have the gear and vs combined in the legend. So a red circle means gear = 3, vs = 0; a red triangle means gear = 3, vs = 1; etc.
... just like the ones in the following posts about R:
How to merge color, line style and shape legends in ggplot
Combine legends for color and shape into a single legend
Is this possible in plotnine? Any help is greatly appreciated!