<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599</link>
    <title>MATLAB Central Newsreader - Single colorbar on figure with subplots?</title>
    <description>Feed for thread: Single colorbar on figure with subplots?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 13 Mar 2009 14:58:42 -0400</pubDate>
      <title>Single colorbar on figure with subplots?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599#634628</link>
      <author>agkonings@gmail.com</author>
      <description>My gut tells me this should be relatively simple, but I can't figure&lt;br&gt;
it out.&lt;br&gt;
&lt;br&gt;
I have a figure with four images as subplots (2 by 2). Each has the&lt;br&gt;
same color scaling, so I would like to display all of them with a&lt;br&gt;
single colorbar along the side (or bottom) of the entire figure.&lt;br&gt;
However, the basic colorbar settings seem to force me to choose a&lt;br&gt;
single set of axes (one of the subplots) to place the colorbar near.&lt;br&gt;
Does anybody know how I might get around this?&lt;br&gt;
&lt;br&gt;
Thanks for your help!&lt;br&gt;
Alexandra</description>
    </item>
    <item>
      <pubDate>Fri, 13 Mar 2009 17:31:11 -0400</pubDate>
      <title>Re: Single colorbar on figure with subplots?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599#634681</link>
      <author>Bill  Comisky</author>
      <description>On Mar 13, 10:58=A0am, agkoni...@gmail.com wrote:&lt;br&gt;
&amp;gt; My gut tells me this should be relatively simple, but I can't figure&lt;br&gt;
&amp;gt; it out.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have a figure with four images as subplots (2 by 2). Each has the&lt;br&gt;
&amp;gt; same color scaling, so I would like to display all of them with a&lt;br&gt;
&amp;gt; single colorbar along the side (or bottom) of the entire figure.&lt;br&gt;
&amp;gt; However, the basic colorbar settings seem to force me to choose a&lt;br&gt;
&amp;gt; single set of axes (one of the subplots) to place the colorbar near.&lt;br&gt;
&amp;gt; Does anybody know how I might get around this?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks for your help!&lt;br&gt;
&amp;gt; Alexandra&lt;br&gt;
&lt;br&gt;
Create a new axis just for your colorbar (see axes() command) that&lt;br&gt;
covers your whole figure (overlaps other axes).  Make sure you set&lt;br&gt;
caxis() the same for each axis.  You can use set() on the output from&lt;br&gt;
axes() to set the 'position' and 'visibility' to what you want.  You&lt;br&gt;
might have to tweak the position of your other subplots to make room&lt;br&gt;
if necessary.&lt;br&gt;
&lt;br&gt;
Bill</description>
    </item>
    <item>
      <pubDate>Sun, 12 Apr 2009 07:30:03 -0400</pubDate>
      <title>Re: Single colorbar on figure with subplots?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599#642080</link>
      <author>Adam </author>
      <description>Bill  Comisky &amp;lt;bcomisky@gmail.com&amp;gt; wrote in message &amp;lt;a9fadb42-55fe-49bb-89ee-13cdcede6289@l16g2000yqo.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On Mar 13, 10:58=A0am, agkoni...@gmail.com wrote:&lt;br&gt;
&amp;gt; &amp;gt; My gut tells me this should be relatively simple, but I can't figure&lt;br&gt;
&amp;gt; &amp;gt; it out.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I have a figure with four images as subplots (2 by 2). Each has the&lt;br&gt;
&amp;gt; &amp;gt; same color scaling, so I would like to display all of them with a&lt;br&gt;
&amp;gt; &amp;gt; single colorbar along the side (or bottom) of the entire figure.&lt;br&gt;
&amp;gt; &amp;gt; However, the basic colorbar settings seem to force me to choose a&lt;br&gt;
&amp;gt; &amp;gt; single set of axes (one of the subplots) to place the colorbar near.&lt;br&gt;
&amp;gt; &amp;gt; Does anybody know how I might get around this?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thanks for your help!&lt;br&gt;
&amp;gt; &amp;gt; Alexandra&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Create a new axis just for your colorbar (see axes() command) that&lt;br&gt;
&amp;gt; covers your whole figure (overlaps other axes).  Make sure you set&lt;br&gt;
&amp;gt; caxis() the same for each axis.  You can use set() on the output from&lt;br&gt;
&amp;gt; axes() to set the 'position' and 'visibility' to what you want.  You&lt;br&gt;
&amp;gt; might have to tweak the position of your other subplots to make room&lt;br&gt;
&amp;gt; if necessary.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Bill&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
% begin plotting routine&lt;br&gt;
close all&lt;br&gt;
figure('Color',[1 1 1]);&lt;br&gt;
x1 = 0:12:288;&lt;br&gt;
x2 = 0:15:285;&lt;br&gt;
% define the timesteps of interest&lt;br&gt;
y1 = 1.5:0.044:36.5; % define the y-axis (height in this case)&lt;br&gt;
y2 = [1.5,3.,5.,7.,10.,15.,20.,25.,30.,33.,37.];&lt;br&gt;
[x1,y1] = meshgrid(x1,y1);  % build the plot matrix&lt;br&gt;
[x2,y2] = meshgrid(x2,y2);  % build the plot matrix&lt;br&gt;
z1 = data_clip(:,114:138);  % span of interest&lt;br&gt;
z3 = towerProfile(:,98:117);  % select the data to plot&lt;br&gt;
rotate3d&lt;br&gt;
subplot(2,1,1); pcolor(x1,y1,z1)&lt;br&gt;
view([0.5 90]);&lt;br&gt;
shading interp&lt;br&gt;
colormap(jet)&lt;br&gt;
grid off&lt;br&gt;
% Create colorbar&lt;br&gt;
c=colorbar ('FontSize',18);&lt;br&gt;
ylabel(c,'Degrees C')&lt;br&gt;
subplot(2,1,2); pcolor(x2,y2,z3)&lt;br&gt;
axis tight&lt;br&gt;
view([0.5 90]);&lt;br&gt;
shading interp&lt;br&gt;
colormap(jet)          &lt;br&gt;
grid off &lt;br&gt;
% Create colorbar&lt;br&gt;
c=colorbar ('FontSize',18);&lt;br&gt;
ylabel(c,'Degrees C')&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;</description>
    </item>
    <item>
      <pubDate>Sun, 12 Apr 2009 12:50:01 -0400</pubDate>
      <title>Re: Single colorbar on figure with subplots?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599#642099</link>
      <author>Oliver Woodford</author>
      <description>&quot;Adam &quot; &amp;lt;kennaster@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; 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.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % begin plotting routine&lt;br&gt;
&amp;gt; close all&lt;br&gt;
&amp;gt; figure('Color',[1 1 1]);&lt;br&gt;
&amp;gt; x1 = 0:12:288;&lt;br&gt;
&amp;gt; x2 = 0:15:285;&lt;br&gt;
&amp;gt; % define the timesteps of interest&lt;br&gt;
&amp;gt; y1 = 1.5:0.044:36.5; % define the y-axis (height in this case)&lt;br&gt;
&amp;gt; y2 = [1.5,3.,5.,7.,10.,15.,20.,25.,30.,33.,37.];&lt;br&gt;
&amp;gt; [x1,y1] = meshgrid(x1,y1);  % build the plot matrix&lt;br&gt;
&amp;gt; [x2,y2] = meshgrid(x2,y2);  % build the plot matrix&lt;br&gt;
&amp;gt; z1 = data_clip(:,114:138);  % span of interest&lt;br&gt;
&amp;gt; z3 = towerProfile(:,98:117);  % select the data to plot&lt;br&gt;
&amp;gt; rotate3d&lt;br&gt;
&amp;gt; subplot(2,1,1); pcolor(x1,y1,z1)&lt;br&gt;
&amp;gt; view([0.5 90]);&lt;br&gt;
&amp;gt; shading interp&lt;br&gt;
&amp;gt; colormap(jet)&lt;br&gt;
&amp;gt; grid off&lt;br&gt;
&amp;gt; % Create colorbar&lt;br&gt;
&amp;gt; %c=colorbar ('FontSize',18);&lt;br&gt;
&amp;gt; %ylabel(c,'Degrees C')&lt;br&gt;
&amp;gt; subplot(2,1,2); pcolor(x2,y2,z3)&lt;br&gt;
&amp;gt; axis tight&lt;br&gt;
&amp;gt; view([0.5 90]);&lt;br&gt;
&amp;gt; shading interp&lt;br&gt;
&amp;gt; colormap(jet)          &lt;br&gt;
&amp;gt; grid off &lt;br&gt;
&amp;gt; % Create colorbar&lt;br&gt;
axes('Position', [0.05 0.05 0.9 0.9], 'Visible', 'off');&lt;br&gt;
&amp;gt; c=colorbar ('FontSize',18);&lt;br&gt;
&amp;gt; ylabel(c,'Degrees C')&lt;br&gt;
&lt;br&gt;
See inline edits.</description>
    </item>
    <item>
      <pubDate>Sun, 12 Apr 2009 18:06:51 -0400</pubDate>
      <title>Re: Single colorbar on figure with subplots?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599#642138</link>
      <author>AMK</author>
      <description>Hi Thanks for the edits.  This does add the single color bar to reference two sufrace plots in a subplot, but it appears to decouple the colorbar values from the original data.  For example, max(z1) and max(z2) are both around 14, but the new single color bar goes from 0 - 80.  What is this new colorbar axes referencing?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Adam</description>
    </item>
    <item>
      <pubDate>Sun, 12 Apr 2009 19:33:01 -0400</pubDate>
      <title>Re: Single colorbar on figure with subplots?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599#642149</link>
      <author>Oliver Woodford</author>
      <description>AMK &amp;lt;kennaster@gmail.com&amp;gt; wrote:&amp;lt;17701574.29089.1239559642450.JavaMail.jakarta@nitrogen.mathforum.org&amp;gt;...&lt;br&gt;
&amp;gt; Hi Thanks for the edits.  This does add the single color bar to reference two sufrace plots in a subplot, but it appears to decouple the colorbar values from the original data.  For example, max(z1) and max(z2) are both around 14, but the new single color bar goes from 0 - 80.  What is this new colorbar axes referencing?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; Adam&lt;br&gt;
&lt;br&gt;
It's referencing nothing. Grab the handle to the colorbar and set the limits manually.</description>
    </item>
    <item>
      <pubDate>Sun, 12 Apr 2009 21:35:01 -0400</pubDate>
      <title>Re: Single colorbar on figure with subplots?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599#642160</link>
      <author>AMK</author>
      <description>Would this be a setting in the colorbar inspector?  I changed the y-scale to 5 - 16, but it just takes the area visible at the previous scale resulting in a color bar that is really just a single color because it's still scaled to 1 - 60.</description>
    </item>
    <item>
      <pubDate>Mon, 13 Apr 2009 08:31:08 -0400</pubDate>
      <title>Re: Single colorbar on figure with subplots?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599#642226</link>
      <author>AMK</author>
      <description>Solved.  Thanks OW and Pixel at Kluid.com for this one.&lt;br&gt;
&lt;br&gt;
A(1)=subplot(2,1,1); mesh(x,y,z)&lt;br&gt;
A(2)=subplot(2,1,2); mesh(x,y,z)&lt;br&gt;
B=colorbar; &lt;br&gt;
set(B, 'Position', [.8314 .11 .0581 .8150]) &lt;br&gt;
for i=1:2 &lt;br&gt;
pos=get(A(i), 'Position'); &lt;br&gt;
axes(A(i)) &lt;br&gt;
set(A(i), 'Position', [pos(1) pos(2) .6626 pos(4)]) &lt;br&gt;
end</description>
    </item>
    <item>
      <pubDate>Sat, 19 Feb 2011 20:51:24 -0500</pubDate>
      <title>Re: Single colorbar on figure with subplots?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/246599#820329</link>
      <author>Eric </author>
      <description>AMK &amp;lt;kennaster@gmail.com&amp;gt; wrote in message &amp;lt;16583380.29435.1239572132296.JavaMail.jakarta@nitrogen.mathforum.org&amp;gt;...&lt;br&gt;
&amp;gt; Would this be a setting in the colorbar inspector?  I changed the y-scale to 5 - 16, but it just takes the area visible at the previous scale resulting in a color bar that is really just a single color because it's still scaled to 1 - 60.&lt;br&gt;
&lt;br&gt;
Use the property 'Clim' to set colorbar limits for all subplots.&lt;br&gt;
e.g.:&lt;br&gt;
&lt;br&gt;
for cz = 1:8&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% Create subplot&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;subplot1(cz) = subplot(2,4,cz,'Parent',figure1,'CLim',[0 8]);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% Create contour&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;contour(x,y,values_19(:,:,cz),'ShowText','on','LineWidth',1,'LineStyle','none',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Fill','on',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'LevelStep',0.5,...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'DisplayName','values(:,:,1)',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Parent',subplot1(cz));&lt;br&gt;
&lt;br&gt;
end</description>
    </item>
  </channel>
</rss>

