如何在pyqtgraph PlotWidget中添加字符串轴

时间:2018-09-05 07:02:18

标签: python-2.7 pyqt pyqtgraph

我正在尝试添加带有字符串((2,3,5,1),(11:30 pm,12:00am,12:30am,1:00am)的x轴。我已经看到一个由addPlot(axisItems)Show string values on x-axis in pyqtgraph使用pytgraph.GraphicsWindow()完成的示例,但是没有用于PlotWidget()添加x轴的addPlot。

1 个答案:

答案 0 :(得分:0)

GraphicsWindows继承自GraphicsLayout,其addPlot方法创建一个PlotItem,然后将其所有参数传递给PlotItem构造函数。

PlotWidget类包装单个PlotItem,并且PlotWidget构造函数还将其参数传递给PlotItem构造函数。

因此,您应该只能够将axisItems参数传递给PlotWidget构造函数。像这样:

myPlotWidget = PlotWidget(axisItems={'bottom': stringaxis})