Strange behaviour of grid and AxisItems in pg.GraphicsLayoutWidget

36 views
Skip to first unread message

fscl...@gmail.com

unread,
Aug 17, 2016, 4:58:28 AM8/17/16
to pyqtgraph
Hello,

I am making an application that adds plots from data selected in a QListWidget.
Each time that I press plot, a new subplot is added to the GraphicsLayoutwidget

I define the axis configuration in this function:

    def FormatAxis(self):
        global frVec3rdOct
        global frXAxis
        global frYAxis
        global rpmXAxis
        global rpmYAxis

        frXAxis=pg.AxisItem(orientation='bottom')
        frYAxis=pg.AxisItem(orientation='left')
                
        frXAxis.setLabel(text='Freq 1/3 Oct',units='Hz')
        frYAxis.setLabel(text='SPL',units='dB(A)')
        frXAxis.setGrid(255)
        frYAxis.setGrid(255)

        rpmXAxis=pg.AxisItem(orientation='bottom')
        rpmYAxis=pg.AxisItem(orientation='left')
        
        rpmXAxis.setLabel(text='Engine Speed',units='RPM')
        rpmYAxis.setLabel(text='SPL',units='dB(A)')
        rpmXAxis.setGrid(255)
        rpmYAxis.setGrid(255)

And each time that I add a nex plot I do it in this way:

            self.wm2=self.pg.GraphicsLayoutWidget.addPlot(row=1, col=0, title = 'Group 2',axisItems={'bottom':rpmXAxis,'left':rpmYAxis})
            self.wm2.addLegend()

The strange behaviour is:

- It appears two small axes in the corner of the plots
- In some of them the grid is plotted, In some of the dont
- Some liked axis stop working (not all!)
- In the plots in log format the plot is replotted on top when I change from one tab to other...

Any ideas??? Is a bug or I am doing somethinh wrong??




fscl...@gmail.com

unread,
Aug 18, 2016, 5:50:07 AM8/18/16
to pyqtgraph
I just Read from an old post that the problem of the samll axis appering in the corner can be solved modifyint the code in plotItem.py line 170 as follows:

        for k, pos in (('top', (1,1)), ('bottom', (3,1)), ('left', (2,0)), ('right', (2,2))):
            if k in axisItems:
                axis = axisItems[k]
            else:
                axis = AxisItem(orientation=k, parent=self)
            axis.linkToView(self.vb)
            self.axes[k] = {'item': axis, 'pos': pos}
            self.layout.addItem(axis, *pos)
            axis.setZValue(-1000)
            axis.setFlag(axis.ItemNegativeZStacksBehindParent)

Does it continues being valid or have been updated?
Reply all
Reply to author
Forward
0 new messages