注意
前往結尾以下載完整的範例程式碼。
美元刻度#
使用格式字串在 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()

參考
此範例展示了以下函數、方法、類別和模組的用法