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.
Below is the code.
import sys
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
##### Override class #####classNonScientific(pg.AxisItem):
def__init__(self, *args, **kwargs):
super(NonScientific, self).__init__(*args, **kwargs)
deftickStrings(self, values, scale, spacing):
return [int(value*1) for value in values] #This line return the NonScientific notation valueclassMyApplication(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()
defPlotContour(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()
defmain():
app = MyApplication(sys.argv)
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Post a Comment for "Pyqtgraph Y Axis Label Non Scientific Notation"