how to set position and outerposition respectively the same as from another axes?
12 次查看(过去 30 天)
显示 更早的评论
I want to display a scalebar on a 3d plot. When I rotate the 3d plot, I want to keep the scalebar still. The way I approach it is to create another axes, copying the same xlim, ylim, zlim, etc properties, plot a line as the scalebar, and lastly axis off;
I however encounter a strange problem. It seems not able to set position and outerposition simultaneously the same, which should be doable but I didn't get it yet.
Please help. below is my scalebar function. input h is from h=subplot(231) for example.
function scalebar(h)
obj=findobj('tag','scalebar');
if ~isempty(obj),delete(obj);end
haxes=axes;set(haxes,'tag','scalebar');
ylim=get(h,'ylim');set(haxes,'ylim',ylim);
xlim=get(h,'xlim');set(haxes,'xlim',xlim);
zlim=get(h,'zlim');set(haxes,'zlim',zlim);
ytick=get(h,'ytick');set(haxes,'ytick',ytick);
xtick=get(h,'xtick');set(haxes,'xtick',xtick);
ztick=get(h,'ztick');set(haxes,'ztick',ztick);
DataAspectRatio=get(h,'DataAspectRatio');set(haxes,'DataAspectRatio',DataAspectRatio);
bar_um=10;
line([-0.5 0.5]*bar_um,[0 0],'color','k');
text(-0.3*bar_um,-0.2*bar_um,[ num2str(bar_um) '\mum'],'fontsize',18);
% axis off
axis on;axis vis3d;grid on;view(0,0); % for debug
pos=get(h,'position');
pos(1)=pos(1)+0.05;
pos(2)=pos(2)-0.1;
set(haxes,'position',pos);
axes(h);
clc % below for debug
get(h,'position')
get(haxes,'position')
get(h,'outerposition')
get(haxes,'outerposition')
end
0 个评论
回答(1 个)
Jan
2012-7-20
No, you cannot set the 'position' and the 'outerposition' to the same value.
Type this in the command window to find the corresponing documentation:
docsearch outerposition
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Visual Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!