1

我尝试重现 Python ggplot 的教程示例,我安装的pip install ggplot这个示例来自 yhat 网站http://blog.yhathq.com/posts/ggplot-for-python.html

import pandas as pd
from ggplot import *

meat_lng = pd.melt(meat, id_vars=['date'])

p = ggplot(aes(x='date', y='value'), data=meat_lng)
p + geom_point() + \
    stat_smooth(colour="red") + \
    facet_wrap("variable")

p + geom_hist() + facet_wrap("color")

p = ggplot(diamonds, aes(x='price'))
p + geom_density() + \
    facet_grid("cut", "clarity")

p = ggplot(diamonds, aes(x='carat', y='price'))
p + geom_point(alpha=0.25) + \
    facet_grid("cut", "clarity")

我得到:

NameError                                 Traceback (most recent call last)
<ipython-input-15-41e6a9d7443f> in <module>()
      5 p + geom_point() +     stat_smooth(colour="red") +     facet_wrap("variable")
      6 
----> 7 p + geom_hist() + facet_wrap("color")
      8 
      9 p = ggplot(diamonds, aes(x='price'))

NameError: name 'geom_hist' is not defined
4

1 回答 1

4

geom_hist()重命名为geom_histogram(). 见这里: http: //ggplot.yhathq.com/docs/geom_histogram.html

于 2014-08-17T15:31:34.377 回答