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)