Python ggplot中的geom_hist()

时间:2014-08-17 08:42:03

标签: python-ggplot

我尝试重现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

1 个答案:

答案 0 :(得分:4)

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