<div dir="ltr"><span style="font-size:12.8px">Hi Jody,</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thanks for your reply.  I'm aware of Matplotlib's animation API.  I'm not sure that it would help me.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">As far as I can tell, the purpose of animation.FuncAnimation() is to connect a data generating function to the update function of a MPL object, and to drive it all with a timer.  It's an event loop, for people who aren't already writing event-driven code (which I am, I have 1,200 lines of mostly-working PyQt5).  What actually gets done in the MPL update method is what I think is important to me.  I want to change only what needs to be changed.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">My approach is best described by this article:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><a href="http://bastibe.de/2013-05-30-speeding-up-matplotlib.html" target="_blank">http://bastibe.de/2013-05-30-speeding-up-matplotlib.html</a></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">The article is a few years old, I know.  Still, using the advice I found in articles like this one, I limited redrawing, and everything updates in under 10 milliseconds, a 15-fold improvement over my original redraw-everything approach. In total, I have five live graphs on the screen. It's only this one self-adjusting time series graph that is misbehaving for me.</div><div class="" style="margin:2px 0px 0px;font-size:12.8px"><div id=":18h" class="" tabindex="0"><img class="" src="https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif" style=""></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 29, 2016 at 3:36 PM, Jody Klymak <span dir="ltr"><<a href="mailto:jklymak@uvic.ca" target="_blank">jklymak@uvic.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Jun 29, 2016, at  15:12 PM, John Ladasky <<a href="mailto:jladasky@itu.edu" target="_blank">jladasky@itu.edu</a>> wrote:</div><div><div dir="ltr"><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I am using MPL 1.4.2, Python 3.4, and Ubuntu 15.04.  I am developing a program which displays real-time data.  On each update cycle, the graph needs to adjust the y-axis scale.  I have code that mostly works, but when it re-renders the y-axis, it is not completely erasing the old one.  I get tick labels written on top of each other, until everything is an unreadable smear, like this:</div></div></div></blockquote><div><br></div></span><div>I think thats because `redraw_in_frame()` doesn’t update any of the axes data…</div><div><br></div><div>Have you looked into the animation API?  Its meant for this sort of thing, and seems pretty snappy.  Most of what you are doing below would just go into the `animate` function. </div><div><br></div><div><a href="http://matplotlib.org/examples/animation/simple_anim.html" target="_blank">http://matplotlib.org/examples/animation/simple_anim.html</a></div><div><br></div><div>Cheers,   Jody</div><div><br></div><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><span><For matplotlib-users.png></span><br></div><span class=""><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Here is the relevant part of my update method:</div><div style="font-size:12.8px"><br></div><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="monospace, monospace" size="1">self.plot.set_data(self.x[:size], self.y[:size])</font></div><div><font face="monospace, monospace" size="1">lo = self.y[:size].min()</font></div><div><font face="monospace, monospace" size="1">hi = self.y[:size].max()</font></div><div><font face="monospace, monospace" size="1">if hi - lo > 150:</font></div><div><font face="monospace, monospace" size="1">    self.ax.set_ylim(lo-25, hi+25)</font></div><div><font face="monospace, monospace" size="1">else:</font></div><div><font face="monospace, monospace" size="1">    mid = self.y[:size].mean()</font></div><div><font face="monospace, monospace" size="1">    self.ax.set_ylim(mid-100, mid+100)</font></div><div><font face="monospace, monospace" size="1">self.ax.relim()</font></div><div><font face="monospace, monospace" size="1">self.ax.autoscale_view(None, False, True)</font></div><div><font face="monospace, monospace" size="1">self.ax.redraw_in_frame()</font></div><div><font face="monospace, monospace" size="1"># Something which erases the Y axis should go here?</font></div><div><font face="monospace, monospace" size="1">self.ax.get_yaxis().draw(self.parent.get_renderer())</font></div></blockquote><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I think that the details of setting the Y limits are unimportant, but I've included that code anyway, so that you can see my set_data() method call at the top, and you can also see that I'm continually adjusting the Y range to track the data.  </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I think that I am searching for a method in the axis class which would erase the previously drawn tick marks and labels.  So far, I haven't found one.  It would replace the comment line in my code.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I am trying to avoid redrawing the entire canvas on which this plot is embedded, since there are several other live data plots besides the one I have shown. The first version of my program did a full redraw, and it took over 150 milliseconds to complete an update call.  That's too slow for my needs.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thanks for any help you can provide!</div><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><b>John J. Ladasky Jr., Ph.D.</b><div><b>Research Scientist</b></div><div><b>International Technological University</b></div><div><b>2711 N. First St, San Jose, CA 95134 USA</b></div></div></div>
</span></div>
_______________________________________________<br>Matplotlib-users mailing list<br><a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br><a href="https://mail.python.org/mailman/listinfo/matplotlib-users" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br></div></blockquote></div><br></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><b>John J. Ladasky Jr., Ph.D.</b><div><b>Research Scientist</b></div><div><b>International Technological University</b></div><div><b>2711 N. First St, San Jose, CA 95134 USA</b></div></div></div>
</div>