python画图模块_学习python画图模块plotnine:第一步安装
官網(wǎng)鏈接
https://plotnine.readthedocs.io/en/stable/index.html
知乎介紹的文章
https://zhuanlan.zhihu.com/p/47814353
簡單介紹
語法類似于R語言的ggplot2包的python畫圖模塊
安裝
按照官網(wǎng)教程直接使用pip安裝
pip?install?plotnine
遇到報錯
ERROR: Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
搜索一番找到說可以在pip命令后加參數(shù)--ignore-installed certifi
于是使用命令安裝
pip?install?-i?https://pypi.tuna.tsinghua.edu.cn/simple?plotnine?--ignore-installed?certifi
這次安裝成功沒有報錯
python中嘗試導(dǎo)入這個模塊
from?plotnine?import?*
提示
Bad?key?animation.mencoder_path?in?file?C:\Users\mingy\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\mpl-data\stylelib\_classic_test.mplstyle,?line?509?('animation.mencoder_path:?mencoder')
You?probably?need?to?get?an?updated?matplotlibrc?file?from
https://github.com/matplotlib/matplotlib/blob/v3.3.1/matplotlibrc.template
or?from?the?matplotlib?source?distribution
搜索了一番,發(fā)現(xiàn)有人說可以卸載已經(jīng)安裝的matplotlib然后再重新安裝試試 使用pip命令卸載
pip?uninstall?matplotlib
重新安裝命令
python?-m?pip?install?-U?matplotlib?--prefer-binary?-i?https://pypi.tuna.tsinghua.edu.cn/simple
matplotlib升級到了3.3.1 沒有遇到報錯 打開python然后再導(dǎo)入plotnine模塊
from?plotnine?import?*
這次沒有任何提示了
接下來試著運行其中的一個例子
from?plotnine?import?*
from?plotnine.data?import?mtcars
ggplot(mtcars,aes(x='wt',y='mpg',color='factor(gear)'))+geom_point()
image.png
ggplot(mtcars,aes(x='wt',y='mpg',color='factor(gear)'))+geom_point()+facet_wrap('~gear',scales="free")
image.png
保存為pdf文件
(ggplot(mtcars,aes(x='wt',y='mpg',color='factor(gear)'))+geom_point()+facet_wrap('~gear',scales="free")).save("Desktop/p1.pdf")
歡迎大家關(guān)注我的公眾號
小明的數(shù)據(jù)分析筆記本
公眾號二維碼.jpg
總結(jié)
以上是生活随笔為你收集整理的python画图模块_学习python画图模块plotnine:第一步安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: javascript --- 将DOM
- 下一篇: 课题申报书范文_2018年课题立项申报书