0

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?

Lukas
  • 1,503
  • 16
  • 20

2 Answers2

1

There is not currently a way to replace an existing axis; use a subclass as you suggested.

Luke
  • 11,020
  • 2
  • 47
  • 59
0

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)
tonyjosi
  • 641
  • 8
  • 13