Plotting order can be hard to figure out in matplotlib. I suggest you use the 
custom viewer class in examples/phase/anisotropy.py as template, along these 
lines:

----

class YunTauViewer(Matplotlib2DGridViewer):
    def __init__(self, phi, title=None, limits={}, **kwlimits):
        self.phi = phi
        self.contour = None
        Matplotlib2DGridViewer.__init__(self, vars=phi[0]+phi[1]+phi[2]+phi[3], 
title=title,
                                        cmap=plt.cm.hot, 
                                        limits=limits, **kwlimits)
                                
    def _plot(self):
        Matplotlib2DGridViewer._plot(self)
        
        if self.contour is not None:
            for contour in self.contour:
                for c in contour.collections:
                    c.remove()
                
        mesh = self.phi[0].mesh
        shape = mesh.shape
        x, y = [a.reshape(shape, order="FORTRAN") for a in mesh.cellCenters]
        self.contour = []
        
        for phi in self.phi:
            z = phi.value.reshape(shape, order="FORTRAN")
            
            self.contour.append(self.axes.contour(x, y, z))

if __name__ == '__main__':
    viewer = YunTauViewer(phi=(phi1, phi2, phi3, phi4),
                          title='time zero',
                          xmin=-l/4, xmax=l/4, ymin=-l/4, ymax=l/4,
                          legend=None)


----

> On Jun 15, 2016, at 8:17 PM, Yun Tao <[email protected]> wrote:
> 
> Hi FiPy community,
> 
> I'm solving a system of 2-dimensional PDEs in time, trying to plot the 
> changing contour lines of individual solutions together with a map of their 
> sum values.
> 
> In the attached example, I defined four uncoupled diffusion equations with 
> separate centers. I solved them simultaneously, plotted each solution using 
> the contour function in matplotlib, and plotted their sum using a FiPy viewer 
> function. 
> 
> However, I noticed that the plots are layered only when my FiPy viewer calls 
> Matplotlib2DGridContourViewer (line 55), but not when I try to use 
> Matplotlib2DGridViewer or Matplotlib2DViewer, both of which failed to render 
> any image when the other contour functions are called. 
> 
> My problem requires me to generate a heat map of the solutions' sum, so I'm 
> wondering if there's any way to work around this pesky issue.
> 
> Thanks,
> Yun
> 
> -- 
> Yun Tao
> Postdoc 
> Center for Infectious Disease Dynamics
> Pennsylvania State University
> State College, PA 16803
> <fipy_example.py>_______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]


_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to