#Rstats's ggplot2 library is powerful and well-organized. There is a #Python library that uses the same "grammar of graphics".
https://towardsdatascience.com/how-to-use-ggplot2-in-python-74ab8adec129
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.