How to disable screen update in matplotlib
I have a loop that is adding a line to a plot on each iteration. Right now this is horribly slow as it seems to redraw the the whole graph each time. Is it possible to disable screen updates for a graph while it is being set 开发者_JS百科up then re-enable them afterwards.
Here's the code:
for rr,dd in zip(angles,dists):
if dd == inf:
pass
else:
lineend = (array([cos(rr), sin(rr)]) * dd)+origin;
plot([origin[0], lineend[0]], [origin[1], lineend[1]],'-b');
I know I should just combine this all into one call to plot
and I'll probably do it for this example. But there are other bits where that would be more of a problem so a general solution would be really helpful.
Thanks!
It sounds like you have the interactive mode on
, so you should just set it to off
using the command
ioff()
Note that when interactive mode is off, you'll need to use the command show()
to display the plots.
精彩评论