About rotary axis label in matlab

I draw some 3D data with a Matlab waterfall, I found that if I set an x- or y-tag using the xlabel or ylabel buildin command, the orientation of the label will always be horizontal rather than aligned with the axis. Is there any way to make it oriented along the axis? I found in the help that we can use the command

xlabel('label at 45 degree', 'rot', 45) 

to indicate the angle of orientation, but if I rotate the three-dimensional axis manually, the label will not change accordingly, anyway, to fix this? Thanks.

+4
source share
1 answer

You cannot do this automatically. You must replace the tic labels / X label with a text object and rotate it yourself ( see here for how to do this ). A simple solution is as follows:

 plot(1:100); % make the axis smaller pos = get(gca, 'Position'); set(gca,'Position',[pos(1), .2, pos(3) 0.7]); % place custom text instead of xlabel % note that the position is relative to your X/Y axis values t = text(50, -5, {'X-axis' 'label'}, 'FontSize', 14); set(t,'HorizontalAlignment','right','VerticalAlignment','top', ... 'Rotation',45); 

Check out this contribution to FEX .

+4
source

Source: https://habr.com/ru/post/1438113/


All Articles