how to make matplotlib faster?

John, I think the push/pop functions are going to be fairly

    > useful (ipush and ipop??). We're going to be writing a lot
    > scripts (i.e. functions) that generate plots for our users.
    > There is no way to tell inside the script if it's going to be
    > used by a user in interactive mode or by another script (like
    > a batch report generator). Having push/pop would let me do:

    > def stdPlot( [inputs] ): ipush( False ) try: [ create plot ]
    > finally: ipop()

    > Of course it's pretty easy to roll your own but I think it
    > would be nice to have it in the standard set of commands.

Hi Ted,

I hadn't thought of using a stack. What is the argument for a stack
as opposed to a single state manipulated along the lines of (with try
except as needed)

b = isinteractive()
ioff()
....your plot here...
if b: ion()

Your approach requires one fewer line of code. Are their other
advantages to a stack approach? I think a stack may be slightly less
intuitive to a typical user, whereas turning drawing mode on and off
is fairly straight forward.

JDH

John,
There probably isn't a compulsive argument for either way of doing it. The stack method is a very common graphics programming method for handling context switches, rotations, etc. Most graphics systems use the idea of pushing and popping from a graphics context stack so you can do rotations and transformations inside a subroutine w/o messing up anything else.

At least where I work, our style guidelines make it a little more verbose. I need to use descriptive variable names (for maintainability) and no one line if statements (which cause problems whenever you need to add debugging print or other statements). Here's the difference between the methods with an additional option thrown in:

···

-------------
Option 1) push/pop

ipush()
try:
    [ ... plot ... ]
finally:
    ipop()

-------------
Option 2) flags

restoreInteractive = isinteractive()
ioff()
try:
    [ ... plot ... ]
finally:
    if restoreInteractive:
       ion()

-------------
Option 3) set/get method

interactiveOn = isinteractive()
ioff()
try:
    [ ... plot ... ]
finally:
    setinteractive( interactiveOn )

Ted

At 12:50 PM 12/13/2004, John Hunter wrote:

Hi Ted,

I hadn't thought of using a stack. What is the argument for a stack
as opposed to a single state manipulated along the lines of (with try
except as needed)

b = isinteractive()
ioff()
....your plot here...
if b: ion()

Your approach requires one fewer line of code. Are their other
advantages to a stack approach? I think a stack may be slightly less
intuitive to a typical user, whereas turning drawing mode on and off
is fairly straight forward.

JDH

    > John, I think the push/pop functions are going to be fairly
    > useful (ipush and ipop??). We're going to be writing a lot
    > scripts (i.e. functions) that generate plots for our users.
    > There is no way to tell inside the script if it's going to be
    > used by a user in interactive mode or by another script (like
    > a batch report generator). Having push/pop would let me do:

    > def stdPlot( [inputs] ): ipush( False ) try: [ create plot ]
    > finally: ipop()

    > Of course it's pretty easy to roll your own but I think it
    > would be nice to have it in the standard set of commands.

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users