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!