使用工程记数法标记刻度
现在我们将使用工程记数法标记 x 轴上的刻度。在第一个子图中,我们将使用默认设置,在第二个子图中,我们将使用 places
和 sep
选项来指定小数点后的位数以及数字与前缀/单位之间的分隔符。
## Demo of the default settings, with a user-defined unit label.
ax0.set_title('Full unit ticklabels, w/ default precision & space separator')
formatter0 = EngFormatter(unit='Hz')
ax0.xaxis.set_major_formatter(formatter0)
ax0.plot(xs, ys)
ax0.set_xlabel('Frequency')
## Demo of the options `places` (number of digit after decimal point) and
## `sep` (separator between the number and the prefix/unit).
ax1.set_title('SI-prefix only ticklabels, 1-digit precision & '
'thin space separator')
formatter1 = EngFormatter(places=1, sep="\N{THIN SPACE}") ## U+2009
ax1.xaxis.set_major_formatter(formatter1)
ax1.plot(xs, ys)
ax1.set_xlabel('Frequency [Hz]')