Path: news.mathworks.com!not-for-mail
From: "Adam " <kennaster@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Single colorbar on figure with subplots?
Date: Sun, 12 Apr 2009 07:30:03 +0000 (UTC)
Organization: Oregon State University
Lines: 60
Message-ID: <grs59r$9t2$1@fred.mathworks.com>
References: <f45e357b-0fbc-41e3-a6c8-e9fc6929364e@q9g2000yqc.googlegroups.com> <a9fadb42-55fe-49bb-89ee-13cdcede6289@l16g2000yqo.googlegroups.com>
Reply-To: "Adam " <kennaster@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1239521403 10146 172.30.248.38 (12 Apr 2009 07:30:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 12 Apr 2009 07:30:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1798037
Xref: news.mathworks.com comp.soft-sys.matlab:532112


Bill  Comisky <bcomisky@gmail.com> wrote in message <a9fadb42-55fe-49bb-89ee-13cdcede6289@l16g2000yqo.googlegroups.com>...
> On Mar 13, 10:58=A0am, agkoni...@gmail.com wrote:
> > My gut tells me this should be relatively simple, but I can't figure
> > it out.
> >
> > I have a figure with four images as subplots (2 by 2). Each has the
> > same color scaling, so I would like to display all of them with a
> > single colorbar along the side (or bottom) of the entire figure.
> > However, the basic colorbar settings seem to force me to choose a
> > single set of axes (one of the subplots) to place the colorbar near.
> > Does anybody know how I might get around this?
> >
> > Thanks for your help!
> > Alexandra
> 
> Create a new axis just for your colorbar (see axes() command) that
> covers your whole figure (overlaps other axes).  Make sure you set
> caxis() the same for each axis.  You can use set() on the output from
> axes() to set the 'position' and 'visibility' to what you want.  You
> might have to tweak the position of your other subplots to make room
> if necessary.
> 
> Bill

I have the same problem and your response doesn't make any sense.  I've posted this query on the Matlab Forum I'm sorry if a double post has occurred.

Given this simple but working script, could you provide a practical example of what you mean?  I couldn't find an actual working example anywhere online.

% begin plotting routine
close all
figure('Color',[1 1 1]);
x1 = 0:12:288;
x2 = 0:15:285;
% define the timesteps of interest
y1 = 1.5:0.044:36.5; % define the y-axis (height in this case)
y2 = [1.5,3.,5.,7.,10.,15.,20.,25.,30.,33.,37.];
[x1,y1] = meshgrid(x1,y1);  % build the plot matrix
[x2,y2] = meshgrid(x2,y2);  % build the plot matrix
z1 = data_clip(:,114:138);  % span of interest
z3 = towerProfile(:,98:117);  % select the data to plot
rotate3d
subplot(2,1,1); pcolor(x1,y1,z1)
view([0.5 90]);
shading interp
colormap(jet)
grid off
% Create colorbar
c=colorbar ('FontSize',18);
ylabel(c,'Degrees C')
subplot(2,1,2); pcolor(x2,y2,z3)
axis tight
view([0.5 90]);
shading interp
colormap(jet)          
grid off 
% Create colorbar
c=colorbar ('FontSize',18);
ylabel(c,'Degrees C')