4

我正在用 matlab 的瀑布图绘制一些 3 维数据,我发现如果我使用内置 xlabel 或 ylabel 命令设置 x 或 y 标签,标签的方向将始终是水平的,而不是与轴对齐。有没有办法让它沿轴定向?我在帮助中发现我们可以使用命令

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

指定方向的角度,但如果我手动旋转 3D 轴,标签不会相应改变,无论如何要解决这个问题?谢谢。

4

1 回答 1

4

您不能自动执行此操作。您必须用文本对象替换 tic 标签/X 标签并自己旋转它(请参阅此处了解如何操作)。简单的解决方案如下所示:

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);

也看看这个 FEX 贡献

于 2012-10-06T12:27:32.817 回答