Distance between axis label and axis in MATLAB figure

后端 未结 3 1064
后悔当初
后悔当初 2021-02-03 09:54

I\'m plotting some data with MATLAB and I\'d like to adjust the distance between axis label and the axis itself. However, simply adding a bit to the \"Position\" property of the

3条回答
  •  日久生厌
    2021-02-03 10:49

    I know this has been answered and all, but this is (to some extent) a simpler way:

    relative_offset = 1.5;
    close all;
    figure(99);clf
    plot(rand(1,10))
    xlabel('The x-axis')
    xh = get(gca,'XLabel'); % Handle of the x label
    pause(0.2)
    set(xh, 'Units', 'Normalized')
    pause(0.2)
    pos = get(xh, 'Position');
    set(xh, 'Position',pos.*[1,relative_offset,1])
    

    I have included the pause commands, since my system will get ahead of itself in some weird way otherwise.

    /Niels

提交回复
热议问题