On 05/10/2006 16:30 Daniel Wheeler wrote the following:
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.
Thanks for your effort to correct this problem! After I edited the code
as you instructed, I did get a nice image with a proper colorbar.
However, I still find that the viewer plots the concentration
upsidedown, i.e. the top part should has higher concentration and the
bottom has much lower concentration, but the viewer plots the other way
around. For more details, please refer to the schematic diagram and the
code I sent to you in my previous emails.
Sorry for the hassle. Viewers are hard for us to get right as they are
not included in our test suite. We will
most probably release an update version 1.1.1 with the bug fixes to
the viewers.
Do not worry about this. I learned a lot from this process, which is
good for a beginner. I have written a small piece of code in MATLAB and
I could use it to do the visualizations before we get this right in FiPy.