On Oct 5, 2006, at 5:02 AM, hzhatlboro wrote:
Not sure if I understand your solution properly. I replaced the viewer part with your code and the figure looks better but without a color bar. The error message prompted is listed below:-
Traceback (most recent call last):
File "C:/Python23/hzh/Q061004-fixed.py", line 26, in ?
viewer = Matplotlib2DViewer(vars=c, limits={'datamin':0., 'datamax':1.})
File "C:\Python23\Lib\site-packages\fipy\viewers\matplotlibViewer\matplotlib2DViewer.py", line 83, in __init__
self.colorbar = pylab.colorbar(array(self.vars[0]))
File "C:\Python23\Lib\site-packages\matplotlib\pylab.py", line 363, in colorbar
edgecolor=edgecolor)
File "C:\Python23\Lib\site-packages\matplotlib\figure.py", line 701, in colorbar
cmap = mappable.cmap
AttributeError: cmap
The updated code is as below:-
from fipy.viewers.matplotlibViewer.matplotlib2DViewer import Matplotlib2DViewer
viewer = Matplotlib2DViewer(vars=c, limits={'datamin':0., 'datamax':1.})
viewer.plot()
Found another bug. These bugs may have been caused by a change in version of matplotlib after 1.1 was released,
I am not sure. Anyhow, to make this work correctly, you need to go to
C:\Python24\lib\site-packages\fipy\viewers\matplotlibViewer\matplotlib2DViewer.py
and change line 83 from
>>> self.colorbar = pylab.colorbar(array(self.vars[0]))
to
>>> self.colorbar = pylab.colorbar()
while you are at it, you may want to edit matplotlib2DGridViewer.py, line 111 (not necessary to fix the above, but worth doing) from:
>>> return reshape(array(self.vars[0]), self.vars[0].getMesh().getShape()) to
>>> return reshape(array(self.vars[0]), self.vars[0].getMesh().getShape()[::-1])
to make that work correctly as well.