I've been trying to add a colorbar to my figure and have used the following code;
cax = axes([0.85, 0.1, 0.075, 0.8])
colorbar(cax=cax)
as a template (from http://matplotlib.sourceforge.net/examples/pylab_examples/subplots_adjust.html)
However I get an error:
Traceback (most recent call last):
File "cornwall2.py", line 640, in <module>
draw_parishes(n_parishes,m_parishes,preoccratio_parishes,0,nthroot,scaling)
File "cornwall2.py", line 112, in draw_parishes
colorbar(cax=cax)
File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\pyplot.py", line 1295, in colorbar
ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\figure.py", line 977, in colorbar
cb = cbar.Colorbar(cax, mappable, **kw)
File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\colorbar.py", line 595, in __init__
mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
AttributeError: 'NoneType' object has no attribute 'autoscale_None'
How am I using colorbar incorrectly?
I think I realised what I was doing wrong, I didn't have the imshow() call beforehand in my program:
But using the code:
cax = fig.add_axes([0.85, 0.1, 0.075, 0.8])
a=outer(arange(0,1,0.01),ones(10))
imshow(a,aspect='auto',cmap=cm.gray,origin='lower')
I get a set of axes from 0 to 10 in the x direction and 0 to 100 in y.How do I get rid of the x axis and scale the y axis from 0 to 1.
David
David Trethewey wrote:
···
I've been trying to add a colorbar to my figure and have used the following code;
cax = axes([0.85, 0.1, 0.075, 0.8])
colorbar(cax=cax)
as a template (from http://matplotlib.sourceforge.net/examples/pylab_examples/subplots_adjust.html)
However I get an error:
Traceback (most recent call last):
File "cornwall2.py", line 640, in <module>
draw_parishes(n_parishes,m_parishes,preoccratio_parishes,0,nthroot,scaling)
File "cornwall2.py", line 112, in draw_parishes
colorbar(cax=cax)
File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\pyplot.py", line 1295, in colorbar
ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\figure.py", line 977, in colorbar
cb = cbar.Colorbar(cax, mappable, **kw)
File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\colorbar.py", line 595, in __init__
mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
AttributeError: 'NoneType' object has no attribute 'autoscale_None'
How am I using colorbar incorrectly?
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
Managed to solve the problem now.
David
David Trethewey wrote:
···
I think I realised what I was doing wrong, I didn't have the imshow() call beforehand in my program:
But using the code:
cax = fig.add_axes([0.85, 0.1, 0.075, 0.8])
a=outer(arange(0,1,0.01),ones(10))
imshow(a,aspect='auto',cmap=cm.gray,origin='lower')
I get a set of axes from 0 to 10 in the x direction and 0 to 100 in y.How do I get rid of the x axis and scale the y axis from 0 to 1.
David
David Trethewey wrote:
I've been trying to add a colorbar to my figure and have used the following code;
cax = axes([0.85, 0.1, 0.075, 0.8])
colorbar(cax=cax)
as a template (from http://matplotlib.sourceforge.net/examples/pylab_examples/subplots_adjust.html)
However I get an error:
Traceback (most recent call last):
File "cornwall2.py", line 640, in <module>
draw_parishes(n_parishes,m_parishes,preoccratio_parishes,0,nthroot,scaling)
File "cornwall2.py", line 112, in draw_parishes
colorbar(cax=cax)
File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\pyplot.py", line 1295, in colorbar
ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\figure.py", line 977, in colorbar
cb = cbar.Colorbar(cax, mappable, **kw)
File "c:\python25\lib\site-packages\matplotlib-0.98.3.0001-py2.5-win32.egg\matplotlib\colorbar.py", line 595, in __init__
mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
AttributeError: 'NoneType' object has no attribute 'autoscale_None'
How am I using colorbar incorrectly?
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options