There is not currently a way to replace an existing axis; use a subclass as you suggested.
Can I replace an AxisItem on a Qt Creator promoted pyqtgraph widget?
-
26-06-2022 - |
Question
I place a widget in Qt Creator and promote it to a PyQtGraph PlotWidget. I'd like to use a custom AxisItem with that widget. Is there any way to replace the existing axis or do I have to subclass PlotWidget?
Solution
OTHER TIPS
Still there isnt a way to replace existing axis without promoting to a PlotWidget
subclass as mentioned in the other answers. For someone looking for an example subclass for PlotWidget
that uses x axis as DateAxisItem
here it is:
from pyqtgraph import PlotWidget, DateAxisItem
class XDateTimeAxis_PlotWidget(PlotWidget):
def __init__(self, parent=None, background='default', plotItem=None, **kargs):
super(XDateTimeAxis_PlotWidget, self).__init__(parent=parent, background=background, plotItem=plotItem, axisItems = {'bottom': DateAxisItem()}, **kargs)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow