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()?
The cost from the tick layout and formatting -- this could be made
more efficient but that is where the cost is currently. For every
tick label, matplotlib does a layout assuming you may have passed a
rotated multiline string. Special casing the no newline, non-rotated
case is probably where the biggest win would come from. It is
a good project for someone to tackle, but the text layout code is kind
of hairy because it deals with so many cases: mathtext, usetex,
rotated strings, multiline strings, top/bottom left/right alignment,
and so on.
A complete refactoring of ticks to treat them as a single
collection-like object rather than a bunch of independent objects
would also help a lot here.
JDH
Thanks for the detailed reply. I was just wondering whether I was missing something obvious and
that doesn’t seem to be the case.
Cheers
Daniel Wheeler
···
On Aug 2, 2006, at 2:15 PM, John Hunter wrote:
“Daniel” == Daniel Wheeler <daniel.wheeler@…582…> writes:
> 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()?
The cost from the tick layout and formatting – this could be made
more efficient but that is where the cost is currently. For every
tick label, matplotlib does a layout assuming you may have passed a
rotated multiline string. Special casing the no newline, non-rotated
case is probably where the biggest win would come from. It is
a good project for someone to tackle, but the text layout code is kind
of hairy because it deals with so many cases: mathtext, usetex,
rotated strings, multiline strings, top/bottom left/right alignment,
and so on.
A complete refactoring of ticks to treat them as a single
collection-like object rather than a bunch of independent objects
would also help a lot here.
JDH
Daniel Wheeler