2016-04-04 13 views
2

filexchangeにthis submissionを使用して同じ画像に2つのカラーバーを配置しました。最初のものは長いなぜ誰もが知っていカラーバーeastoutside vs westoutside

colorbar('EastOutside') 

colorbar('WestOutside') 

によって第2の1の位置:

enter image description here

最初のカラーバーの位置

がで設定されています?

Matlab documentationを見ると、同じであるはずです。私は何が欠けていますか?

コードの骨格は、以下である:

%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'); 
+0

プロットの作成方法を示すコードをさらに投稿することをお勧めします。 – Dan

+0

素敵なプロット!最初に軸を作成してから、この軸を明示的に指定してカラーバーを追加してから、明示的に軸を指定してプロットを行います。最初のカラーマップは、軸が作成される前に作成されているように見えるので、プロットによってサイズが変更される可能性があります。 –

+0

@HughNolanありがとう、しかし、私はそれを行う方法を知らない。最初に軸を作成してからプロットを作成するにはどうしたらいいですか? – shamalaia

答えて

1

キーが2つの異なる軸を使用することです。それは、これを作成し

%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; 

enter image description here

MATLABの2015aを使用してコードに基づきます。

関連する問題