@
目录有的时候我们并不想显示科学计数,不直观。
如果数值不是特别大,还是直接显示数值比较直观。
import numpy as np import pyqtgraph as pg class LogStringAxis(pg.AxisItem): def logTickStrings(self, values, scale, spacing): estrings = ["%0.1f" % x for x in 10**np.array(values).astype(float)] return estrings win = pg.GraphicsWindow() logStringAxis = LogStringAxis(orientation='bottom') plot = win.addPlot(axisItems={'bottom': logStringAxis}) plot.setLogMode(True, False) x1 = np.linspace(0, 20000, 500) y1 = np.linspace(0, 1, 500) curve = plot.plot(x1, y1) if __name__ == '__main__': import sys if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'): pg.QtGui.QApplication.exec_()