如何在 Matplotlib 中更改科学计数法的字体大小?
若要更改 matplotlib 中科学计数法的字号,我们可以采取以下步骤——
设置图形的大小,并调整子图之间的边距。
列出 x 和 y 的值。
使用 plot() 方法绘制 x 和 y 数据点。
若要更改科学计数法的字号,我们可以使用样式名 style="sci"。
若要显示图形,请使用 show() 方法。
示例
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = [10000, 20000, 300000, 34, 1, 10000] y = [1, 2, 0, 4, 1, 5] plt.plot(x, y, color='red') plt.ticklabel_format(axis="x", style="sci", scilimits=(0, 0)) plt.show()
输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP