Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 453
LihaoZ Avatar asked Aug 02 '16 09:08

LihaoZ


1 Answers

You can use:

p.save('test.png')
like image 134
Yaron Neuman Avatar answered Sep 20 '22 08:09

Yaron Neuman