我尝试使用ggplot for 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来表示它:
^{pr2}$但得到的错误是:
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)>
>>>
我该怎么做才能进一步显示图形?在
我们也可以使用ggplot libraryqplot中的另一个函数来绘制图形。假设上述数据集幂函数数据作为输入。我们可以把它描绘成:
import qplot from ggplot qplot(power_data[:,0], power_data[:,1], type='l')
我错过了三个重要步骤:
1)首先,数据需要采用如下格式:
2)那么数据需要用
^{pr2}$DataFrame
来修饰3)如果没有
plt.show(1)
图将不会显示下面是解决上述问题的代码:
或可选地在一个过程中没有
for
,如comment中所提供:相关问题 更多 >
编程相关推荐