colorbase AttributeError: 'AxesImage' problem

Friends,
I tried to incorporate an example script for colorbar given in the following link into my code.

http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

When i run the program, i get the following error. I didnt use set_ylabel option in my code. I am not getting why this error appears. Kindly help me by writting why this error comes. I have attached the code with the mail.

Thanks,
Bala

Traceback (most recent call last):
File “./test.py”, line 27, in
cb = mpl.colorbar.ColorbarBase(map, cmap=cmap,norm=norm,boundaries=[0]+bound+[9],extend=‘both’,ticks=boun
File “/usr/lib/python2.5/site-packages/matplotlib/colorbar.py”, line 221, in init
self.set_label(’’)
File “/usr/lib/python2.5/site-packages/matplotlib/colorbar.py”, line 302, in set_label
self._set_label()
File “/usr/lib/python2.5/site-packages/matplotlib/colorbar.py”, line 292, in _set_label
self.ax.set_ylabel(self._label, **self._labelkw)
AttributeError: ‘AxesImage’ object has no attribute ‘set_ylabel’

test.py (696 Bytes)

Friends,
I tried to incorporate an example script for colorbar given in the
following link into my code.

http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

When i run the program, i get the following error. I didnt use
set_ylabel option in my code. I am not getting why this error appears.
Kindly help me by writting why this error comes. I have attached the
code with the mail.

Please include the data file so we can run your example to test it, or (better) modify your test script to generate fake data so that it doesn't need a data file.

Eric

···

On 07/13/2010 07:12 AM, Bala subramanian wrote:

Thanks,
Bala

Traceback (most recent call last):
   File "./test.py", line 27, in <module>
     cb = mpl.colorbar.ColorbarBase(map,
cmap=cmap,norm=norm,boundaries=[0]+bound+[9],extend='both',ticks=boun
   File "/usr/lib/python2.5/site-packages/matplotlib/colorbar.py", line
221, in __init__
     self.set_label('')
   File "/usr/lib/python2.5/site-packages/matplotlib/colorbar.py", line
302, in set_label
     self._set_label()
   File "/usr/lib/python2.5/site-packages/matplotlib/colorbar.py", line
292, in _set_label
     self.ax.set_ylabel(self._label, **self._labelkw)
AttributeError: 'AxesImage' object has no attribute 'set_ylabel'

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Eric,
Sorry for not providing the test data. Attached herewith both my script and test data.

Bala

test.py (696 Bytes)

test.rms (48.8 KB)

···

On Tue, Jul 13, 2010 at 9:14 PM, Eric Firing <efiring@…202…> wrote:

On 07/13/2010 07:12 AM, Bala subramanian wrote:

Friends,

I tried to incorporate an example script for colorbar given in the

following link into my code.

http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

When i run the program, i get the following error. I didnt use

set_ylabel option in my code. I am not getting why this error appears.

Kindly help me by writting why this error comes. I have attached the

code with the mail.

Please include the data file so we can run your example to test it, or

(better) modify your test script to generate fake data so that it

doesn’t need a data file.

Eric

Thanks,

Bala

Traceback (most recent call last):

File “./test.py”, line 27, in

 cb = mpl.colorbar.ColorbarBase(map,

cmap=cmap,norm=norm,boundaries=[0]+bound+[9],extend=‘both’,ticks=boun

File “/usr/lib/python2.5/site-packages/matplotlib/colorbar.py”, line

221, in init

 self.set_label('')

File “/usr/lib/python2.5/site-packages/matplotlib/colorbar.py”, line

302, in set_label

 self._set_label()

File “/usr/lib/python2.5/site-packages/matplotlib/colorbar.py”, line

292, in _set_label

 self.ax.set_ylabel(self._label, **self._labelkw)

AttributeError: ‘AxesImage’ object has no attribute ‘set_ylabel’


This SF.net email is sponsored by Sprint

What will you do first with EVO, the first 4G phone?

Visit sprint.com/firsthttp://p.sf.net/sfu/sprint-com-first


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


This SF.net email is sponsored by Sprint

What will you do first with EVO, the first 4G phone?

Visit sprint.com/firsthttp://p.sf.net/sfu/sprint-com-first


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Eric,
Sorry for not providing the test data. Attached herewith both my script
and test data.

Bala

     > Friends,
     > I tried to incorporate an example script for colorbar given in the
     > following link into my code.
     >
     > http://matplotlib.sourceforge.net/examples/api/colorbar_only.html
     >
     > When i run the program, i get the following error. I didnt use
     > set_ylabel option in my code. I am not getting why this error
    appears.
     > Kindly help me by writting why this error comes. I have attached the
     > code with the mail.

    Please include the data file so we can run your example to test it, or
    (better) modify your test script to generate fake data so that it
    doesn't need a data file.

    Eric

     >
     > Thanks,
     > Bala
     >
     > Traceback (most recent call last):
     > File "./test.py", line 27, in <module>
     > cb = mpl.colorbar.ColorbarBase(map,
     > cmap=cmap,norm=norm,boundaries=[0]+bound+[9],extend='both',ticks=boun
     > File
    "/usr/lib/python2.5/site-packages/matplotlib/colorbar.py", line
     > 221, in __init__
     > self.set_label('')
     > File
    "/usr/lib/python2.5/site-packages/matplotlib/colorbar.py", line
     > 302, in set_label
     > self._set_label()
     > File
    "/usr/lib/python2.5/site-packages/matplotlib/colorbar.py", line
     > 292, in _set_label
     > self.ax.set_ylabel(self._label, **self._labelkw)
     > AttributeError: 'AxesImage' object has no attribute 'set_ylabel'

The problem is that the ColorbarBase initializer takes an axes as its first argument, and you fed it the AxesImage instance returned by matshow.

You probably don't actually want to be using ColorbarBase at all--I suspect you would do better with a plain old Figure.colorbar() method call. ColorbarBase is more for the situation in the example you started with, where there is no master image to which the colorbar corresponds.

Eric

···

On 07/13/2010 10:02 AM, Bala subramanian wrote:

On Tue, Jul 13, 2010 at 9:14 PM, Eric Firing <efiring@...202... > <mailto:efiring@…202…>> wrote:
    On 07/13/2010 07:12 AM, Bala subramanian wrote:

     >
    ------------------------------------------------------------------------------
     > This SF.net email is sponsored by Sprint
     > What will you do first with EVO, the first 4G phone?
     > Visit sprint.com/first <http://sprint.com/first&gt; --
    http://p.sf.net/sfu/sprint-com-first
     >
     > _______________________________________________
     > Matplotlib-users mailing list
     > Matplotlib-users@lists.sourceforge.net
    <mailto:Matplotlib-users@lists.sourceforge.net>
     > matplotlib-users List Signup and Options

    ------------------------------------------------------------------------------
    This SF.net email is sponsored by Sprint
    What will you do first with EVO, the first 4G phone?
    Visit sprint.com/first <http://sprint.com/first&gt; --
    http://p.sf.net/sfu/sprint-com-first
    _______________________________________________
    Matplotlib-users mailing list
    Matplotlib-users@lists.sourceforge.net
    <mailto:Matplotlib-users@lists.sourceforge.net>
    matplotlib-users List Signup and Options

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options