Hi Eric,

2011/6/6 Eric Firing <efir...@hawaii.edu>:
> It's not quite clear to me yet, but I assume you want to use a call to
> imshow with a different data set in the second subplot, but have the
> color scale and colorbar be identical to those in the first subplot.  Is
> that correct?  If so, all you need to do is use the same norm for both
> calls to imshow--that is, define a norm, set the limits you want on it,
> and supply it as a kwarg.

thanks a lot, you helped me to work around my problem, see code below :)

> Also, for this sort of comparison, sometimes it is more efficient to use
> a single colorbar for multiple panels, as in this example:
>
>  http://matplotlib.sourceforge.net/examples/pylab_examples/multi_image.html

Very nice example! It's a little too complex for me, though, with all
the calculations for the axes layout -- I prefer subplots :) However,
I think I have found a nice compromise:

import pylab
import matplotlib as mpl

pylab.close('all')

dat = pylab.array([[1,2,3,4],[5,6,7,8]])
datT = dat/2

fig = pylab.figure()

ax1 = fig.add_subplot(211)
ax1.set_title('raw data')
im1 = ax1.imshow(dat, interpolation='nearest',
cmap=mpl.cm.get_cmap('rainbow', 20))
fig.colorbar(im1)

ax2 = fig.add_subplot(212)
ax2.set_title('leveled')
im2 = ax2.imshow(datT, interpolation='nearest',
cmap=mpl.cm.get_cmap('rainbow', 20))
## apply norm:
norm = mpl.colors.Normalize(vmin=dat.min(), vmax=dat.max())
im2.set_norm(norm)
fig.colorbar(im2)

## doesn't really work :/
cax = fig.add_axes([0.25, 0.04, 0.5, 0.02])
fig.colorbar(im2, cax, orientation='horizontal')

pylab.show()

Thanks a lot,
best regards,

Daniel

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to