我尝试将ggplot 用于 python我有以下数据:
power_data = [[ 4.13877565e+04, 2.34652000e-01],
[ 4.13877565e+04, 2.36125000e-01],
[ 4.13877565e+04, 2.34772000e-01],
...
[ 4.13882896e+04, 2.29006000e-01],
[ 4.13882896e+04, 2.29019000e-01],
[ 4.13882896e+04, 2.28404000e-01]]
我想用ggplot来表示它:
print ggplot(aes(x='TIME', y='Watts'), data=power_data) + \
geom_point(color='lightblue') + \
geom_line(alpha=0.25) + \
stat_smooth(span=.05, color='black') + \
ggtitle("Power comnsuption over 13 hours") + \
xlab("Time") + \
ylab("Watts")
但得到错误:
File "C:\PYTHON27\lib\site-packages\ggplot\ggplot.py", line 59, in __init__
for ae, name in self.aesthetics.iteritems():
AttributeError: 'list' object has no attribute 'iteritems'
>>>
我不知道这条线aes(x='TIME', y='Watts')
应该做什么。
如何格式化power_data
列表以便可以将其与 ggplot 一起使用,我希望第一列在x
时间轴上表示,第二列在功率y
轴上?
如果我正在尝试使用该meat
示例,它不会显示任何内容,它只会显示
>>> print (ggplot(aes(x='date', y='beef'), data=meat) + \
... geom_line())
<ggplot: (20096197)>
>>>
我应该怎么做才能进一步显示图形?