首页 文章

关于在matlab中旋转轴标签

提问于
浏览
4

我正在使用matlab的瀑布绘制一些三维数据,我发现如果我使用buildin xlabel或ylabel命令设置x或y标签,标签的方向将始终是水平的而不是与轴对齐 . 是否有任何方法使其沿轴线定向?我在帮助中发现我们可以使用该命令

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

指定方向角但是如果我手动旋转3D轴,标签不会相应改变,无论如何要修复它?谢谢 .

1 回答

  • 4

    你不能自动完成 . 您必须将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 .

相关问题