我一直在尝试使用 gnuplot.py 打印以下数据:
data = [[datetime.datetime(2013, 1, 15, 17, 45), 16.00], [datetime.datetime(2013, 1, 16, 17, 45), 15.98], [datetime.datetime(2013, 1, 17, 17, 45), 15.94]]
所以我是这样开始的:
gp=Gnuplot.Gnuplot()
gp('set data style linespoints')
gp('set xdata time')
gp('set timefmt "%Y-%m-%d"')
gp('set xrange ["2012-12-20":"2013-02-12"]')
gp.plot(data)
我得到以下回应:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/Gnuplot/_Gnuplot.py", line 285, in plot
self._add_to_queue(items)
File "/usr/lib/python2.6/dist-packages/Gnuplot/_Gnuplot.py", line 255, in _add_to_queue
self.itemlist.append(PlotItems.Data(item))
File "/usr/lib/python2.6/dist-packages/Gnuplot/PlotItems.py", line 549, in Data
data = utils.float_array(data[0])
File "/usr/lib/python2.6/dist-packages/Gnuplot/utils.py", line 33, in float_array
return numpy.asarray(m, numpy.float32)
File "/usr/lib/python2.6/dist-packages/numpy/core/numeric.py", line 230, in asarray
return array(a, dtype, copy=False, order=order)
ValueError: setting an array element with a sequence.
然后,我尝试将其转换为以下列表:
[['2013-01-15', 16.00], ['2013-01-16', 15.98], ['2013-01-17', 15.94]]
结果相同。
有谁知道问题出在哪里?
谢谢。