duplicate draw operations in basemap?

Jeff,

Basemap methods like plot() include a "draw_if_interactive" command, followed by a call to the set_axes_limits() method, which ends with

          # force draw if in interactive mode.
         if is_interactive():
             figManager = _pylab_helpers.Gcf.get_active()
             figManager.canvas.draw()

It seems to me that you could eliminate all those "draw_if_interactive" blocks from plot etc., and replace the end block of set_axes_limits() with

         if is_interactive():
             import matplotlib.pyplot as plt
             plt.draw_if_interactive()

The advantages would be reduced clutter in the drawing methods, and consistent use of draw_if_interactive. I think the latter would make interactive running of functions and subclasses built on basemap more efficient by reducing redundant draw operations.

It also looks like at least most of the operations in set_axes_limits really need to be done only once (although I have not checked this carefully). Instead of repeating them with every call to a plotting method, the basemap instance could keep a list of hashes of axes objects on which the operations have already been run, and use that to prevent duplication.

Nothing urgent here--just some ideas that occur to me while working with basemap. If you think any are worth pursuing, and you want me to take a shot at it, let me know.

Eric

Eric Firing wrote:

Jeff,

Basemap methods like plot() include a "draw_if_interactive" command, followed by a call to the set_axes_limits() method, which ends with

          # force draw if in interactive mode.
         if is_interactive():
             figManager = _pylab_helpers.Gcf.get_active()
             figManager.canvas.draw()

It seems to me that you could eliminate all those "draw_if_interactive" blocks from plot etc., and replace the end block of set_axes_limits() with

         if is_interactive():
             import matplotlib.pyplot as plt
             plt.draw_if_interactive()

The advantages would be reduced clutter in the drawing methods, and consistent use of draw_if_interactive. I think the latter would make interactive running of functions and subclasses built on basemap more efficient by reducing redundant draw operations.

It also looks like at least most of the operations in set_axes_limits really need to be done only once (although I have not checked this carefully). Instead of repeating them with every call to a plotting method, the basemap instance could keep a list of hashes of axes objects on which the operations have already been run, and use that to prevent duplication.

Nothing urgent here--just some ideas that occur to me while working with basemap. If you think any are worth pursuing, and you want me to take a shot at it, let me know.

Eric

Eric: You are right, that could be done much more efficiently. I'm stuck in the U.K. waiting for the volcanic dust to clear, so if you want to take a shot at it go ahead.

-Jeff

Jeff Whitaker wrote:

Eric Firing wrote:

Jeff,

Basemap methods like plot() include a "draw_if_interactive" command, followed by a call to the set_axes_limits() method, which ends with

          # force draw if in interactive mode.
         if is_interactive():
             figManager = _pylab_helpers.Gcf.get_active()
             figManager.canvas.draw()

It seems to me that you could eliminate all those "draw_if_interactive" blocks from plot etc., and replace the end block of set_axes_limits() with

         if is_interactive():
             import matplotlib.pyplot as plt
             plt.draw_if_interactive()

The advantages would be reduced clutter in the drawing methods, and consistent use of draw_if_interactive. I think the latter would make interactive running of functions and subclasses built on basemap more efficient by reducing redundant draw operations.

It also looks like at least most of the operations in set_axes_limits really need to be done only once (although I have not checked this carefully). Instead of repeating them with every call to a plotting method, the basemap instance could keep a list of hashes of axes objects on which the operations have already been run, and use that to prevent duplication.

Nothing urgent here--just some ideas that occur to me while working with basemap. If you think any are worth pursuing, and you want me to take a shot at it, let me know.

Eric

Eric: You are right, that could be done much more efficiently. I'm stuck in the U.K. waiting for the volcanic dust to clear, so if you want to take a shot at it go ahead.

-Jeff

Jeff,

I made the changes, and removed a few obsolete bits.

I hope you are cleared to fly soon, if you have not already departed.

Eric

Eric Firing wrote:

Jeff Whitaker wrote:

Eric Firing wrote:

Jeff,

Basemap methods like plot() include a "draw_if_interactive" command, followed by a call to the set_axes_limits() method, which ends with

          # force draw if in interactive mode.
         if is_interactive():
             figManager = _pylab_helpers.Gcf.get_active()
             figManager.canvas.draw()

It seems to me that you could eliminate all those "draw_if_interactive" blocks from plot etc., and replace the end block of set_axes_limits() with

         if is_interactive():
             import matplotlib.pyplot as plt
             plt.draw_if_interactive()

The advantages would be reduced clutter in the drawing methods, and consistent use of draw_if_interactive. I think the latter would make interactive running of functions and subclasses built on basemap more efficient by reducing redundant draw operations.

It also looks like at least most of the operations in set_axes_limits really need to be done only once (although I have not checked this carefully). Instead of repeating them with every call to a plotting method, the basemap instance could keep a list of hashes of axes objects on which the operations have already been run, and use that to prevent duplication.

Nothing urgent here--just some ideas that occur to me while working with basemap. If you think any are worth pursuing, and you want me to take a shot at it, let me know.

Eric

Eric: You are right, that could be done much more efficiently. I'm stuck in the U.K. waiting for the volcanic dust to clear, so if you want to take a shot at it go ahead.

-Jeff

Jeff,

I made the changes, and removed a few obsolete bits.

I hope you are cleared to fly soon, if you have not already departed.

Eric

Eric: I'm still here - hope to get out on Sat at the earliest. Thanks for making those changes - I'm sure they will help a lot for interactive use and animations.

-Jeff