LihaoZ
LihaoZ

Reputation: 181

Python ggplot- ggsave function not defined

I've just started to learn to use python. I'm using anaconda python 3.5 and Rodeo to do a simple 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)

Everything works fine before the 5th line. I got the plot as I wanted. But I got an error when I tried to save the plot:

NameError: name 'ggsave' is not defined

It seems that there's no ggsave function in ggplot module? The ggplot version is 0.11.1. Am I missing something here?

Upvotes: 16

Views: 4339

Answers (1)

Yaron Neuman
Yaron Neuman

Reputation: 102

You can use:

p.save('test.png')

Upvotes: 8

Related Questions