Colorbar eastoutside vs westoutside

I put two colored icons in the same image using this view on filexchange.

enter image description here

The position of the first color bar is set using:

colorbar('WestOutside') 

position of the second:

 colorbar('EastOutside') 

Does anyone know why the first one is longer?

When looking at the Matlab documentation, it seemed to me that they should be the same. What am I missing?

The code skeleton is as follows:

 %define coordinates of the nodes theta=linspace(0,2*pi,33); [x,y]=pol2cart(theta,1); %define colormap of the links cm = winter; colormap(cm); %plot the links for ii=1:N quiver(...) end %place the first colorbar hcb=colorbar('EastOutside'); %freeze the first colorbar cbfreeze(hcb); %define the second colormap cm = autumn; colormap(cm); %plot the dots for ii=1:N plot(...) end %place the second colorbar hb=colorbar('EastOutside'); 
+2
matlab colorbar
source share
1 answer

The key is to use two different axes. Based on your code:

 %define coordinates of the nodes theta=linspace(0,2*pi,33); [x,y]=pol2cart(theta,1); %plot the links close figure; for ii=1:100 quiver(x,y) end %define colormap of the links ax1 = gca; colormap (ax1,winter) %place the first colorbar hcb=colorbar(ax1,'EastOutside'); %this is tentative, just to get the axes right position: hb=colorbar(ax1,'WestOutside'); pos = ax1.Position; hb.delete % second colorbar ax2 = axes; colormap (ax2,autumn) hb=colorbar(ax2,'WestOutside'); ax2.Position = pos; axis off ax1.Position = pos; 

He creates this: enter image description here

Using MATLAB 2015a.

+1
source share

All Articles