📌  相关文章
📜  matplotlib 获取和更改刻度标签的值 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:18.745000             🧑  作者: Mango

代码示例1
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

# We need to draw the canvas, otherwise the labels won't be positioned and 
# won't have values yet.
fig.canvas.draw()

labels = [item.get_text() for item in ax.get_xticklabels()]
labels[1] = 'Testing'

ax.set_xticklabels(labels)

plt.show()