旋转自定义刻度标签#

自定义刻度标签的用户定义旋转演示。

ticklabels rotation
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)
# You can specify a rotation for the tick labels in degrees or with keywords.
ax.set_xticks(x, labels, rotation='vertical')

plt.show()

由 Sphinx-Gallery 生成的画廊