matplotlib.pyplot.ticklabel_format#

matplotlib.pyplot.ticklabel_format(*, axis='both', style=None, scilimits=None, useOffset=None, useLocale=None, useMathText=None)[source]#

配置默认用于线性轴的ScalarFormatter

如果未设置参数,格式化器(formatter)的相应属性将保持不变。

参数:
axis{'x', 'y', 'both'},默认值: 'both'

要配置的轴。仅影响主刻度。

style{'sci', 'scientific', 'plain'}

是否使用科学记数法。格式化器(formatter)默认使用科学记数法。'sci' 等同于 'scientific'。

scilimits整数对 (m, n)

科学记数法仅用于超出 10m 到 10n 范围的数字(并且仅当格式化器(formatter)配置为使用科学记数法时)。使用 (0, 0) 以包含所有数字。使用 (m, m)(其中 m != 0)将数量级固定为 10m。格式化器(formatter)默认值为 rcParams["axes.formatter.limits"](默认值:[-5, 6])。

useOffset布尔值或浮点数

如果为 True,则根据需要计算偏移量。如果为 False,则不使用偏移量。如果为数值,则设置偏移量。格式化器(formatter)默认值为 rcParams["axes.formatter.useoffset"](默认值:True)。

useLocale布尔值

是否使用当前区域设置或 C(英语)区域设置来格式化数字。这会影响例如小数点分隔符。格式化器(formatter)默认值为 rcParams["axes.formatter.use_locale"](默认值:False)。

useMathText布尔值

在 mathtext 中渲染偏移量和科学记数法。格式化器(formatter)默认值为 rcParams["axes.formatter.use_mathtext"](默认值:False)。

引发:
AttributeError

如果当前格式化器(formatter)不是ScalarFormatter

备注