correct plot3d axis label
Afficher commentaires plus anciens
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
Réponses (1)
Sean de Wolski
le 3 Déc 2012
Modifié(e) : Sean de Wolski
le 3 Déc 2012
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 commentaires
joo
le 3 Déc 2012
Sean de Wolski
le 3 Déc 2012
Save the bottom part as rotate_labels.m. Copy the rest into an editor and run it.
joo
le 3 Déc 2012
Catégories
En savoir plus sur Axis Labels dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!