I am trying to add an x-axis with strings ((2,3,5,1),(11:30pm,12:00am,12:30am,1:00am)). I have seen an example that was done using pytgraph.GraphicsWindow() by addPlot(axisItems) Show string values on x-axis in pyqtgraph , but there is no addPlot for PlotWidget() to add a x-axis.
Asked
Active
Viewed 646 times
1 Answers
0
GraphicsWindows
inherits from GraphicsLayout
and its addPlot
method creates a PlotItem
and then passes all its parameters to the PlotItem
constructor.
The PlotWidget
class wraps a single PlotItem
and the PlotWidget
constructor also passes its parameters to the PlotItem
constructor.
Therefore you should just be able to pass the axisItems
parameter to the PlotWidget
constructor. Something like:
myPlotWidget = PlotWidget(axisItems={'bottom': stringaxis})

titusjan
- 5,376
- 2
- 24
- 43
-
Thanks titusjan, but if i pass stringaxis when initializing the PlotWidget, how do I update the stringaxis for new plot? – Quazi R Sep 12 '18 at 00:15
-
1I have found a way to add string axis by using setTicks - myPlotWidget = PlotWidget() myPlotWidget.plot((1,2,3,4),(2,3,5,1)) myPlotWidget.getAxis('bottom').setTicks([[(1,"11:30pm"),(2,"12:00am"),(3,"12:30am"),(4,1:00am)]]) – Quazi R Sep 13 '18 at 19:15