Reputation: 1543
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?
Upvotes: 0
Views: 464
Reputation: 835
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)
Upvotes: 0
Reputation: 11644
There is not currently a way to replace an existing axis; use a subclass as you suggested.
Upvotes: 1