Paul,
Thanks for the detailed tutorial. I'm getting errors when I attempt to use
plt.subplots(1,1) and the newcm assignment.
Traceback (most recent call last):
File "colorbar_Mytest2.py", line 17, in <module>
f, ax = plt.subplots(1,1)
AttributeError: 'module' object has no attribute 'subplots'
Here are just a few of the errors I'm getting when executing colorbar command
with newcm. Also, what does In and Out do, as in Out[68]: 0.34999999999999998 ?
plt.draw()
File "/usr/lib/pymodules/python2.6/matplotlib/pyplot.py", line 352, in draw
get_current_fig_manager().canvas.draw()
File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py",
line 215, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", line
314, in draw
self.figure.draw(self.renderer)
File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in
draw_wrapper
draw(artist, renderer, *kl)
File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 773, in draw
for a in self.axes: a.draw(renderer)
File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in
draw_wrapper
Here's a simplified version that works for me:
from matplotlib import pyplot, mpl
import sys,getopt
from mpl_toolkits.basemap import Basemap, shiftgrid, cm
#from netCDF3 import Dataset as NetCDFFile
from mpl_toolkits.basemap import NetCDFFile
from pylab import *
vals = norm(np.linspace(14,40,1000))
newcm = cm.colors.ListedColormap(cm.hot_r(vals))
# Make a figure and axes with dimensions as desired.
fig = pyplot.figure(figsize=(8,3))
#f, ax = plt.subplots(1,1)
ax1 = fig.add_axes([0.05, 0.4, 0.9, 0.14])
#ax2 = fig.add_axes([0.05, 0.8, 0.9, 0.6])
# Set the colormap and norm to correspond to the data for which
# the colorbar will be used.
cmap = mpl.cm.cool
norm = mpl.colors.Normalize(vmin=0, vmax=40) # here set colorbar min/max
mycolormap=cm.hot
maprev = cm.hot_r
#f,(ax2,ax3) = plt.subplots(2,1)
cb2 = mpl.colorbar.ColorbarBase(ax1, cmap=cm.hot_r,
norm=norm,
orientation='horizontal')
#cb2.set_label('"percent"')
#cb3 = mpl.colorbar.ColorbarBase(ax1, cmap=newcm,
# orientation='horizontal')
#cb3.set_label("colormap interval 0.0-1.0")
plt.draw()
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users