一.安装方法:
pip install plotnine
使用的编译器:pycharm
二.plotnine绘图
1.第一个图形
除了导包的操作不一致,其他类似
from plotnine import ggplot, geom_point, aes, stat_smooth, facet_wrap
from plotnine.data import mtcars
(ggplot(mtcars, aes('wt', 'mpg', color='factor(gear)'))
+ geom_point()
+ stat_smooth(method='lm')
+ facet_wrap('~gear'))
如果你和我一样使用的是pycharm这个图形可能不会显示,我们需要先对其赋值,然后print出来
from plotnine import ggplot, geom_point, aes, stat_smooth, facet_wrap
from plotnine.data import mtcars
a = (ggplot(mtcars, aes('wt', 'mpg', color='factor(gear)'))
+ geom_point()
+ stat_smooth(method='lm')
+ facet_wrap('~gear'))
print(a)

2.小提琴图+散点图+箱线图
先来看一下语法:
geom_violin(mapping=None, data=None, stat='ydensity', position='dodge',
na_rm=False, inherit_aes=True, show_legend=None, raster=False,
trim=

最低0.47元/天 解锁文章
1114

被折叠的 条评论
为什么被折叠?



