备注
Go to the end to download the full example code..
美元刻度#
使用格式字符串在 y 轴标签上添加美元符号.
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
fig, ax = plt.subplots()
ax.plot(100*np.random.rand(20))
# Use automatic StrMethodFormatter
ax.yaxis.set_major_formatter('${x:1.2f}')
ax.yaxis.set_tick_params(which='major', labelcolor='green',
labelleft=False, labelright=True)
plt.show()

参考
以下函数,方法,类和模块的用法在本例中显示:
matplotlib.pyplot.subplotsmatplotlib.axis.Axis.set_major_formattermatplotlib.axis.Axis.set_tick_paramsmatplotlib.axis.Tickmatplotlib.ticker.StrMethodFormatter