Follow

's ggplot2 library is powerful and well-organized. There is a library that uses the same "grammar of graphics".

towardsdatascience.com/how-to-

To actually see the graph in the initial example, I had to slightly modify the code:

from plotnine import ggplot, geom_point, aes, stat_smooth, facet_wrap
from plotnine.data import mtcars

plot = (ggplot(mtcars, aes('wt', 'mpg', color='factor(gear)')) +
geom_point() +
stat_smooth(method='lm') +
facet_wrap('~gear'))

plot.save('p9test.png')

The fact that factor(gear) appears as a string gives me pause, but I can live with it.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.