The Python Oracle

set_data and autoscale_view matplotlib

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: RPG Blues Looping

--

Chapters
00:00 Set_data And Autoscale_view Matplotlib
01:06 Accepted Answer Score 53
01:34 Thank you

--

Full question
https://stackoverflow.com/questions/7187...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #matplotlib

#avk47



ACCEPTED ANSWER

Score 53


From the matplotlib docs for autoscale_view:

The data limits are not updated automatically when artist data are changed after the artist has been added to an Axes instance. In that case, use matplotlib.axes.Axes.relim() prior to calling autoscale_view.

So, you'll need to add two lines before your plt.draw() call after the set_data call:

axes.relim()
axes.autoscale_view(True,True,True)