Borrar filtros
Borrar filtros

how to set position and outerposition respectively the same as from another axes?

11 visualizaciones (últimos 30 días)
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

Respuestas (1)

Jan
Jan el 20 de Jul. de 2012
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
  1 comentario
Chaowei Chen
Chaowei Chen el 20 de Jul. de 2012
Hi Jan, sorry that I should clarify my question. I want to create an axes whose position and outerposition respectively same to that of an existing axes. I have verified that it is manually doable but can't get it done by
pos=get(h,'position');
set(haxes,'position',pos);
opos=get(h,'outerposition');
set(haxes,'outerposition',opos);

Iniciar sesión para comentar.

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by