从R语言迁移Python 的过程中意外发现ggplot模块,可以满足Python中使用R语言ggplot2可视化的需求。
ggplot模块安装
- 使用pip安装
pip install ggplot
- 使用easy_install安装
easy_install ggplot
- 登录python第三方模块库下载
登录网址(https://pypi.org/ )检索ggplot,解压缩下载的压缩文件到python的模块安装目录下。
调用ggplot
- 安装完成后进入ipython编辑器;
- 返回如下错误;
- 在确认 ggplot 模块是完整的之后,结合报错推断是 ggplot 模块依赖的 pandas 模块版本的更新导致 Timestamp 无法导入,0.23.3版本的 pandas 模块的 Timestamp 类直接定义在 pandas 下而不在 pandas.lib;
- 打开 smoothers.py 文件,修改 from pandas.lib import Timestamp 为 from pandas import Timestamp;
- 保存文件的修改,重新 import 即可解决。