It seems that resetting the axes limits every time data needs to be redisplayed is rather inefficient. A script is included with this mail that tests the efficiency of resizing the y axis. The script has two loops, in the first loop pylab.ylim() is continuously called with the changing size of the domain, in the second loop pylab.ylim() is not called inside the loop. The first loop takes roughly twice as long to perform. Is this an unavoidable cost for resizing the y axis or is there another way to resize the axis that is less costly than using ylim()? |
import pylab import Numeric import time pylab.ion() fig = pylab.figure() arr = Numeric.zeros(1000) lines = pylab.plot(arr)
arr = Numeric.arange(1000) / 999. arr = arr * (1 - arr) arrmax = max(arr) pylab.ylim(ymin=0) t0 = time.clock() for i in range(100): pylab.figure(fig.number) lines[0].set_ydata(arr) pylab.ylim(ymax=arrmax) pylab.draw() arr *= 0.9 arrmax *= 0.9 print 'time for resetting limits',time.clock() - t0 arr = Numeric.arange(1000) / 999. arr = arr * (1 - arr) pylab.ylim(ymax=max(arr)) t0 = time.clock() for i in range(100): pylab.figure(fig.number) lines[0].set_ydata(arr) pylab.draw() arr *= 0.9 print 'time when not resetting limits',time.clock() - t0
Cheers Daniel Wheeler |
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users