From: <ef...@us...> - 2007-09-03 18:27:26
|
Revision: 3769 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3769&view=rev Author: efiring Date: 2007-09-03 11:27:22 -0700 (Mon, 03 Sep 2007) Log Message: ----------- Added example of a standalone colorbar. Added Paths: ----------- trunk/matplotlib/examples/colorbar_only.py Added: trunk/matplotlib/examples/colorbar_only.py =================================================================== --- trunk/matplotlib/examples/colorbar_only.py (rev 0) +++ trunk/matplotlib/examples/colorbar_only.py 2007-09-03 18:27:22 UTC (rev 3769) @@ -0,0 +1,28 @@ +''' +Make a colorbar as a separate figure. +''' + +import pylab +import matplotlib as mpl + +# Make a figure and axes with dimensions as desired. +fig = pylab.figure(figsize=(8,1.5)) +ax = fig.add_axes([0.05, 0.4, 0.9, 0.5]) + +# 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=5, vmax=10) + +# ColorbarBase derives from ScalarMappable and puts a colorbar +# in a specified axes, so it has everything needed for a +# standalone colorbar. There are many more kwargs, but the +# following gives a basic continuous colorbar with ticks +# and labels. +cb = mpl.colorbar.ColorbarBase(ax, cmap=cmap, + norm=norm, + orientation='horizontal') +cb.set_label('Some Units') + +pylab.show() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |