Skip to content Skip to sidebar Skip to footer

PyQtgraph Y Axis Label Non Scientific Notation

PyQtgraph Y axis label is displaying in scientific notation. I do not want it to be in scientific notation. What is the code to change label to non scientific. Scientific notation

Solution 1:

PyQtgraph does not contain set_scientific(False). The best solution is to override the AxisItem.tickStrings will help to create custom labels.

enter image description here

Below is the code.

import sys
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg

##### Override class #####
class NonScientific(pg.AxisItem):
    def __init__(self, *args, **kwargs):
        super(NonScientific, self).__init__(*args, **kwargs)

    def tickStrings(self, values, scale, spacing):
        return [int(value*1) for value in values] #This line return the NonScientific notation value

class MyApplication(QtGui.QApplication):
    def __init__(self, *args, **kwargs):

        self.win = pg.GraphicsWindow(title="Contour plotting")
        self.win.resize(1000,600)

        self.plot = self.win.addPlot(title='Contour', axisItems={'left': NonScientific(orientation='left')})
        self.curve = self.plot.plot()


    def PlotContour(self):
        x = range(50000,60000,10000)#X coordinates of contour
        y = range(500000,600000,100000)#Y coordinates of contour
        self.curve.setData(x=x, y=y)
        self.curve.autoRange()

def main():
    app = MyApplication(sys.argv)
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()

Post a Comment for "PyQtgraph Y Axis Label Non Scientific Notation"