如何在 set_data() 调用后自动缩放 matplotlib X 和 Y 轴
在 matplotlib 中调用 set_data() 或 set_ydata() 后,轴比例不会自动更新。使用
autoscale_matplotlib.py
ax.relim()
ax.autoscale_view(True,True,True)来更新 X 和 Y 比例。
完整示例:
autoscale_matplotlib_example.py
line.set_data(x, y)
# 自动缩放视图
ax.relim()
ax.autoscale_view(True,True,True)
# 重绘
figure.canvas.draw()
figure.canvas.flush_events()Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow