有没有办法在ggplot中绘制 pandas 系列? [英] Is there a way to plot a pandas series in ggplot?
问题描述
我正在尝试熊猫和非matplotlib绘图.好的建议是此处.这个问题与 yhat的ggplot 有关,我遇到了两个问题. 在大熊猫中绘制系列很容易.
I'm experimenting with pandas and non-matplotlib plotting. Good suggestions are here. This question regards yhat's ggplot and I am running into two issues. Plotting a series in pandas is easy.
frequ.plot()
我在ggplot文档中看不到该怎么做.相反,我最终创建了一个数据框:
I don't see how to do this in the ggplot docs. Instead I end up creating a dataframe:
cheese = DataFrame({'time': frequ.index, 'count' : frequ.values})
ggplot(cheese, aes(x='time', y='count')) + geom_line()
我希望ggplot(一个与熊猫紧密集成的项目)有一种绘制简单系列的方法.
I would expect ggplot -- a project that has "tight integration with pandas" -- to have a way to plot a simple series.
第二个问题是,当x轴是一天中的某个时间时,我无法显示stat_smooth().似乎它可能与此
Second issue is I can't get stat_smooth() to display when the x axis is time of day. Seems like it could be related to this post, but I don't have the rep to post there. My code is:
frequ = values.sampler.resample("1Min", how="count")
cheese = DataFrame({'time': frequ.index, 'count' : frequ.values})
ggplot(cheese, aes(x='time', y='count')) + geom_line() + stat_smooth()
任何有关非matplotlib绘图的帮助将不胜感激.谢谢! (我正在使用ggplot 0.5.8)
Any help regarding non-matplotlib plotting would be appreciated. Thanks! (I'm using ggplot 0.5.8)
推荐答案
这更多是一种解决方法,但您可以使用qplot
来使用系列进行快速简写绘图.
This is more of a workaround but you can use qplot
for quick, shorthand plots using series.
from ggplot import *
qplot(meat.beef)
这篇关于有没有办法在ggplot中绘制 pandas 系列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!