Customize "XTickLabel" location
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm using names rather than values for my x-axis using the script below:
set(gca,'XTickLabel',{'P1', 'P2', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10','P11', 'P12', 'P13', 'Population Mean'});
However, I want my last XTickLabel to be further to the right so it stands out from the rest of the values. I tried different things like blank ' ' labels or placing extra spaces eg. '<space> Population Mean' but it didn't work. Any suggestions?
Thanks,
Rosie
3 Kommentare
Walter Roberson
am 21 Aug. 2017
plot(1:20)
ax = gca;
ax.XTick = [1 2 4 5 6 7 8 9 10 11 12 13 14];
ax.XTickLabel = {'P1', 'P2', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10','P11', 'P12', 'P13', 'Population Mean'};
pause(3);
ax.XTickLabel = {'P1', 'P2', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10','P11', 'P12', 'P13', ' Population Mean'};
In the first version, the 'Population Mean' label will greatly overlap the other labels. Then when it is changed to have a number of spaces before it, you will see it move further right, without having changed the XTick
Antworten (2)
Steven Lord
am 21 Aug. 2017
% Create a new figure and an axes
figure;
ax = axes;
% Change the X limits of the axes
xlim(ax, [1 15]);
% Change the locations of the tick labels
ax.XTick = [1:5 12];
% Change the tick labels themselves
ax.XTickLabel = {'x1', 'x2', 'x3', 'x4', 'x5', 'the rest'};
Note that I've exaggerated the space between the labels 'x5' and 'the rest'; if you just want a little bit of separation maybe put the labels at [1:2:9 12] instead of [1:5 12].
0 Kommentare
Jason Kulpe
am 21 Jun. 2018
I found a way to modify the position of the YAxis for a particular application. Its not exactly what you were looking for but it might help you: here
0 Kommentare
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!