On 06/06/2011 11:33 AM, Daniel Mader wrote: > Hi all, > > I'd like to compare two sets of data by using subplots and imshow(). I > have two issues with this: > > 1) how can I have a colorbar in each subplot? > 2) how can I adjust the range limits for a colorbar, so that the > comparison possible? > > Below is code which could serve as a starting point, I hope it helps > to make my problem clearer...
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. 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 Eric > > Thanks and best regards, > Daniel > > import pylab > #import matplotlib as mpl > import matplotlib.cm as cm # colormaps > #import matplotlib.colors as col # colormaps > > 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') > im = ax.imshow(dat, interpolation='nearest', cmap=cm.get_cmap('rainbow', 20)) > fig.colorbar(im) > > ax2 = fig.add_subplot(212) > ax2.set_title('transformed') > ''' here is missing: > a 2nd colorbar with the same limit than in the first subfig, i.e. 1..8 > ''' > > pylab.show() > > ------------------------------------------------------------------------------ > 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 ------------------------------------------------------------------------------ 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