필터 지우기
필터 지우기

correct plot3d axis label

조회 수: 27 (최근 30일)
joo
joo 2012년 12월 3일
how can i out the label of the axis x and y parallell to the axis like the label of the z axis?
thank you very much

답변 (1개)

Sean de Wolski
Sean de Wolski 2012년 12월 3일
편집: Sean de Wolski 2012년 12월 3일
This comes from one of our KCS documents which will be published externally within the next 24hrs.
surf(peaks);
xlabel('X Label'); ylabel('Y Label'); zlabel('Z label');
%Call this to rotate the labels
rotate_labels(gca);
%Optional Step. Cause labels to chage as figure is rotated
call_when_rotates = @(~,~,hax)(rotate_labels(hax));
hrot = rotate3d;
set(hrot,'ActionPreCallBack',...
@(hfig,event_data)(set(hfig,'WindowButtonMotionFcn',{call_when_rotates event_data.Axes})));
set(hrot,'ActionPostCallBack',...
@(hfig,~)(set(hfig,'WindowButtonMotionFcn','')));
The rotate_labels function is:
function rotate_labels(hax)
M = view(hax);
R = M(1:3,1:3);
x = R*[1;0;0];
y = R*[0;1;0];
z = R*[0;0;1];
set(get(hax,'XLabel'),'rotation',360/(2*pi)*atan(x(2)/x(1)))
set(get(hax,'YLabel'),'rotation',360/(2*pi)*atan(y(2)/y(1)))
  댓글 수: 3
Sean de Wolski
Sean de Wolski 2012년 12월 3일
Save the bottom part as rotate_labels.m. Copy the rest into an editor and run it.
joo
joo 2012년 12월 3일
it changed my plot inside and the label is still not correct. can you tell me what the problem can be please? thank you so much
subplot(224)
plot3([newxa(end) newxa], [newza(end) newza], [newya(end) newya],'k','LineWidth', 3);
xlabel('Ankle X Trajectory (mm)', 'FontSize',10, 'FontName','NewsGotT', 'fontWeight','bold');
ylabel('Ankle Z Trajectory (mm)', 'FontSize',10, 'FontName','NewsGotT', 'fontWeight','bold');
zlabel('Ankle Y Trajectory (mm)', 'FontSize',10,'FontName','NewsGotT', 'fontWeight','bold');
set(gca,'FontSize',10, 'FontName','NewsGotT');
grid on;
surf(peaks);
xlabel('xlabel'); ylabel('ylabel'); zlabel('zlabel');
%Call this to rotate the labels
rotate_labels(gca);
%Optional Step. Cause labels to chage as figure is rotated
call_when_rotates = @(~,~,hax)(rotate_labels(hax));
hrot = rotate3d;
set(hrot,'ActionPreCallBack',...
@(hfig,event_data)(set(hfig,'WindowButtonMotionFcn',{call_when_rotates event_data.Axes})));
set(hrot,'ActionPostCallBack',...
@(hfig,~)(set(hfig,'WindowButtonMotionFcn','')));

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by