我试图使用pyqtgraph绘制时间序列。我已经阅读了这篇文章、这篇文章和这篇文章。但我不确定如何正确使用它。
我的绘图是一个绘图部件,我是这样使用的:
但是我遇到了一个错误:
我的绘图是一个绘图部件,我是这样使用的:
graph.plot(aerosol_data, pen=pg.mkPen(color=colors[count], width=1, style=QtCore.Qt.SolidLine), axisItems={'bottom': TimeAxisItem(orientation='bottom')})
TimeAxisItem的定义如下:
class TimeAxisItem(pg.AxisItem):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def tickStrings(self, values, scale, spacing):
# PySide's QTime() initialiser fails miserably and dismisses args/kwargs
return [useful_values_dict['useful_data']['data']['ISO_dates']]
其中ISO_dates是一个以ISO格式表示的日期和时间列表
我也尝试过这个:
graph.plotItem.plot(aerosol_data, pen=pg.mkPen(color=colors[count], width=1, style=QtCore.Qt.SolidLine), axisItems={'bottom': TimeAxisItem(orientation='bottom')})
但是没有效果(坐标轴仍然是数字)。
接着我尝试使用DateTimeAxis.py:
date_axis = pg.DateAxisItem('bottom', pen=None, linkView=None, parent=None, maxTickLength=-1, showValues=True)
date_axis.tickStrings(useful_values_dict['useful_data']['data']['timestamp_dates'],1, 1)
但是我遇到了一个错误:
File "C:\Python34\lib\site-packages\pyqtgraph\graphicsItems\DateAxisItem.py", line 161, in tickStrings
format_strings.append(x.strftime(tick_spec.format))
AttributeError: 'NoneType' object has no attribute 'format'