Python ggplot- ggsave 函数未定义

标签 python pandas ggplot2

我刚开始学习使用 python。我正在使用 anaconda python 3.5 和 Rodeo 来做一个简单的 ggplot

from ggplot import *
df=pd.DataFrame({"Animal":["dog","dolphin","chicken","ant","spider"],"Legs":[4,0,2,6,8]})
p=ggplot(df, aes(x="Animal", weight="Legs")) + geom_bar(fill='blue')
p
ggsave("test.png",p)

在第 5 行之前一切正常。我得到了我想要的情节。但是当我尝试保存情节时出现错误:

NameError: name 'ggsave' is not defined

ggplot模块好像没有ggsave函数? ggplot 版本为 0.11.1。我在这里遗漏了什么吗?

最佳答案

您可以使用:

p.save('test.png')

关于Python ggplot- ggsave 函数未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38717282/

相关文章:

python - 元素树 - 不循环搜索特定元素值

python - 为什么这个 Python 代码不能通过 SSL 连接?

python - 有没有办法将包含事件持续时间的日期索引数据帧转换为显示每天事件的二进制数据数据帧?

r - 按 ggplot 中躲避位置的因素分组

python - 对键也是字典的字典键进行排序

python - 安装 python 包 Flair 时出错,关于 PyPI 中未托管的依赖包

python - Pandas 计数字典中值的出现

python - Pandas iterrows() row.get() 方法返回系列而不是单元格值

r - ggplot2:为没有重叠的组绘制误差线

r - ggplot2 facet_grid() strip_text_x() 基于因子的不同颜色