在 matplotlib.pyplot 中避免使用科学计数法
matplotlibserver side programmingprogramming更新于 2025/8/30 8:22:17
为了避免使用科学计数法,我们必须在 ticklabel_format 方法中传递 style="plain"。
步骤
传递两个列表,使用 plot() 方法绘制一条线。
使用 ticklabel_format() 方法,并传入 style="plain"。如果未设置参数,则格式化程序的相应属性保持不变。style="plain"关闭科学计数法。
要显示图形,请使用 plt.show() 方法。
示例
from matplotlib import pyplot as plt plt.plot([1, 2, 3, 4, 5], [11, 12, 13, 14, 15]) plt.ticklabel_format(style='plain') # 禁止使用科学计数法。 plt.show()
输出


