Hello, I have the following function as an example. You can see I started to
play with one of the demos to put a colorbar on it. I'm a little confused
how to make this work, as on my figure I have several 'collections'. The
other examples I have seen deal with one collection. Maybe someone could
show how to make a color bar here??
Thanks!
#!/usr/bin/env python
import matplotlib as mpl
import numpy as np
import matplotlib.pyplot as plt
def plot_fill_between(array=None):
""" plot with fill_between for a cumsum vector """
# Set up plotting environment
fig = plt.figure()
nx = 40
ny = 20
if array is None:
X = range(nx)
array = np.random.rand(nx,ny)
array = np.cumsum(array,axis=1)
Nc = np.array([float(i)/ny for i in range(ny)])
norm = mpl.colors.normalize(Nc.min(),Nc.max())
jet = plt.cm.get_cmap('jet')
for i in range(ny-1):
cmap = jet(norm(Nc[i]))
if i == 0:
plt.fill_between(X,np.zeros(len(array[:,i])),array[:,i],color=cmap,label='%s'
% i)
plt.fill_between(X,array[:,i],array[:,i+1],color=cmap,label='%s' %
i)
plt.title('Fill Between Demo')
## ListedColormap
#ax2 = fig.add_axes([0.15, 0.05, 0.75, 0.05])
#cmap = mpl.colors.ListedColormap(range(H.numageclasses))
#cmap.set_over('0.25')
#cmap.set_under('0.75')
## If a ListedColormap is used, the length of the bounds array must be
## one greater than the length of the color list. The bounds must be
## monotonically increasing.
#bounds = range(H.numageclasses+1)
#norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
##cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=cmap,
## norm=norm,
## # to use 'extend', you must
## # specify two extra boundaries:
## boundaries=[0]+bounds+[13],
## extend='both',
## ticks=bounds, # optional
## spacing='proportional',
## orientation='horizontal')
##cb2.set_label('Units')
return fig
if __name__ == "__main__":
fig = plot_fill_between()
plt.show()
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users