Dear Eric,

thanks again for your comment, I am aware that the script contained
both the individual colorbars and the common one. My comment  in the
code was because the placement on the figure is somewhat cramped:

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

Ideally, I'd need to create a new subfig 313 with a much reduced height.

Either way, you helped me a lot!


2011/6/7 Eric Firing <efir...@hawaii.edu>:
> On 06/07/2011 01:37 AM, Daniel Mader wrote:
>>
>> 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:
>
> Attached is a slight modification, much simpler than the example above, but
> retaining the single colorbar.  Alternatively, if you stick with the
> colorbar for each panel (which is sometimes clearer), it illustrates a
> slightly clearer way of handling the cmap and norm, explicitly using the
> same instance of each for both images.
>
> Eric
>
>>
>> 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