彩条Eastoutside vs Westoutside [英] colorbar eastoutside vs westoutside
本文介绍了彩条Eastoutside vs Westoutside的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I put two colorbars in the same image using this submission on filexchange.
第一个颜色条的位置是通过以下方式设置的:
The position of the first colorbar is set by:
colorbar('WestOutside')
第二个位置:
colorbar('EastOutside')
有人知道为什么第一个更长吗?
Does anyone know why the first one is longer?
查看 Matlab文档时,我觉得他们应该是一样的.我想念什么?
When looking at the Matlab documentation it seemed to me that they should be the same. What am I missing?
代码的骨架如下:
%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');
推荐答案
关键是要使用两个不同的轴.根据您的代码:
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;
它创建了这个:
使用MATLAB 2015a.
Using MATLAB 2015a.
这篇关于彩条Eastoutside vs Westoutside的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文