problem using subplots with ion()

Hi. I am trying to output multiple 2D graphs (subplots) in one figure (using pylab) for each time-step that the python code runs - basically an interactive graphs. We use the ‘ion()’ and ‘imshow()’ functions for this. I have many graphs to chose from, but say if I chose 4 graphs to output, all 4 will output for the 1st time step, but for every additional time step only the last graph will update. The first 3 will remain the same, as they were in the 1st time step. Has anyone has this problem? Any suggestions?

A portion of the O-O code is below. This function is called in another file. I tried to add notes where I thought they were helpful.

def multi_display(self, n=4):
   
    ''' displaying multiple graphs '''

    ion() 
    m = self.displayed_multi     # four input graph names (provided when function is called)   
    nsub = n      # no. of subgraphs/time step

    for i in range(nsub): # for each subplot

        p = i +1       
        exec ("self.subplot" + str(p) + " = subplot(2, 2, p)")   # OR subplot(2,2,p)
                  
        self.displayed = m[i]  
        self.display_stand()   # this calls the function below  with 'self.displayed' in it.

def display_stand(self): # displays individual graphs

    if self.displayed == 'ht': # this is only one of the four graphs (or subplots)
       
        vm = 0.0
        vx = 40.0
        t = 'Height (m)'
        imshow(self.old_ht, vmin = vm, vmax = vx,
           interpolation = 'nearest')
        title(t)

Thanks,
Louise

Hi. I am trying to output multiple 2D graphs (subplots) in one figure
(using pylab) for each time-step that the python code runs - basically an
interactive graphs. We use the 'ion()' and 'imshow()' functions for this.
I have many graphs to chose from, but say if I chose 4 graphs to output, all
4 will output for the 1st time step, but for every additional time step only
the last graph will update. The first 3 will remain the same, as they were
in the 1st time step. Has anyone has this problem? Any suggestions?

I'm not sure what exactly an issue here.
You want to know how to keep the first three graph during each step?
Can't you just clear the last axes, and redraw it.

e.g.,

self.subplot4.cla()
self.subplot4.imshow(...)

if you want to stick to the pylab interface (which I don't think a
good idea for application development),

sca(self.subplot4)
cla()
imshow(...)

A snippet of code does not help much.
Please take your time to create a small, standalone script that
reproduces your problem and post that on the mailing list.

Regards,

-JJ

···

On Wed, Jul 15, 2009 at 3:23 PM, Louise Loudermilk<louise.loudermilk@...287...> wrote:

A portion of the O-O code is below. This function is called in another
file. I tried to add notes where I thought they were helpful.

def multi\_display\(self, n=4\):

    &#39;&#39;&#39; displaying multiple graphs &#39;&#39;&#39;

    ion\(\)
    m = self\.displayed\_multi     \# four input graph names \(provided when

function is called)
nsub = n # no. of subgraphs/time step

    for i in range\(nsub\): \# for each subplot

        p = i \+1
        exec \(&quot;self\.subplot&quot; \+ str\(p\) \+ &quot; = subplot\(2, 2, p\)&quot;\)   \# OR

subplot(2,2,p)

        self\.displayed = m\[i\]
        self\.display\_stand\(\)   \# this calls the function below  with

'self.displayed' in it.

def display_stand(self): # displays individual graphs

    if self\.displayed == &#39;ht&#39;: \# this is only one of the four graphs \(or

subplots)

        vm = 0\.0
        vx = 40\.0
        t = &#39;Height \(m\)&#39;
        imshow\(self\.old\_ht, vmin = vm, vmax = vx,
           interpolation = &#39;nearest&#39;\)
        title\(t\)

Thanks,
Louise

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users