How to autoscale matplotlib X&Y axis after set_data() call
After calling set_data() or set_ydata() in matplotlib the axis scale is not updated automatically. Use
autoscale_matplotlib.py
ax.relim()
ax.autoscale_view(True,True,True)to update both the X and the Y scale.
Full example:
autoscale_matplotlib_example.py
line.set_data(x, y)
# Autoscale view
ax.relim()
ax.autoscale_view(True,True,True)
# Redraw
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