【问题标题】:about rotating axis label in matlab关于matlab中的旋转轴标签
【发布时间】:2012-10-06 00:43:09
【问题描述】:

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

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

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

【问题讨论】:

  • 我自己没用过,不过this或许有帮助?

标签: matlab


【解决方案1】:

您不能自动执行此操作。您必须用文本对象替换 tic 标签/X 标签并自己旋转它 (see here to know how to do it)。简单的解决方案如下:

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

也可以看看this FEX contribution

【讨论】:

  • hi angainor,所以不要将其设置为 45 度。无论如何要在程序中找到当前视点的x轴角度吗?谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-20
  • 1970-01-01
  • 2012-04-21
  • 2018-04-02
相关资源
最近更新 更多