前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >学习python画图模块plotnine:第一步安装

学习python画图模块plotnine:第一步安装

作者头像
用户7010445
发布2020-09-03 16:16:02
2K0
发布2020-09-03 16:16:02
举报
官网链接

https://plotnine.readthedocs.io/en/stable/index.html

知乎介绍的文章

https://zhuanlan.zhihu.com/p/47814353

简单介绍

语法类似于R语言的ggplot2包的python画图模块

安装

按照官网教程直接使用pip安装

代码语言:javascript
复制
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命令后加参数--ignore-installed certifi

于是使用命令安装

代码语言:javascript
复制
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple plotnine --ignore-installed certifi

这次安装成功没有报错

python中尝试导入这个模块

代码语言:javascript
复制
from plotnine import *

提示

代码语言:javascript
复制
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

搜索了一番,发现有人说可以卸载已经安装的matplotlib然后再重新安装试试 使用pip命令卸载

代码语言:javascript
复制
pip uninstall matplotlib

重新安装命令

代码语言:javascript
复制
python -m pip install -U matplotlib --prefer-binary -i https://pypi.tuna.tsinghua.edu.cn/simple

matplotlib升级到了3.3.1 没有遇到报错 打开python然后再导入plotnine模块

代码语言:javascript
复制
from plotnine import *

这次没有任何提示了

接下来试着运行其中的一个例子

代码语言:javascript
复制
from plotnine import *
from plotnine.data import mtcars
ggplot(mtcars,aes(x='wt',y='mpg',color='factor(gear)'))+geom_point()

image.png

代码语言:javascript
复制
ggplot(mtcars,aes(x='wt',y='mpg',color='factor(gear)'))+geom_point()+facet_wrap('~gear',scales="free")

image.png

保存为pdf文件

代码语言:javascript
复制
(ggplot(mtcars,aes(x='wt',y='mpg',color='factor(gear)'))+geom_point()+facet_wrap('~gear',scales="free")).save("Desktop/p1.pdf")
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-08-31,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 小明的数据分析笔记本 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档