註
移至結尾以下載完整範例程式碼。
旋轉的刻度標籤#
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 9, 6]
labels = ['Frogs', 'Hogs', 'Bogs', 'Slogs']
fig, ax = plt.subplots()
ax.plot(x, y)
# A tick label rotation can be set using Axes.tick_params.
ax.tick_params("y", rotation=45)
# Alternatively, if setting custom labels with set_xticks/set_yticks, it can
# be set at the same time as the labels.
# For both APIs, the rotation can be an angle in degrees, or one of the strings
# "horizontal" or "vertical".
ax.set_xticks(x, labels, rotation='vertical')
plt.show()

參考文獻
此範例顯示了以下函式、方法、類別和模組的使用