writing all numbers on x axes with plot function
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sermet
am 22 Nov. 2014
Kommentiert: Star Strider
am 22 Nov. 2014
%for example
id=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
north=[100;101;102;103;104;105;106;107;108;109;110;111;112;113;114];
figure;
plot(id,north,'b')
title('NORTH-COORDINATE TIME SERIES')
xlabel('SESSIONS')
ylabel('NORTH')
%I want that every number of id appears on the x axes (not, 0-5-10-15) in the figure.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 22 Nov. 2014
Add a command to specify the 'XTick' values to put every value of ‘id’ on the x-axis:
id=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
north=[100;101;102;103;104;105;106;107;108;109;110;111;112;113;114];
figure;
plot(id,north,'b')
title('NORTH-COORDINATE TIME SERIES')
xlabel('SESSIONS')
ylabel('NORTH')
set(gca, 'XTick',id) % Specify XTick Values
2 Kommentare
Star Strider
am 22 Nov. 2014
Probably the easiest way is to reduce the FontSize:
id=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
north=[100;101;102;103;104;105;106;107;108;109;110;111;112;113;114];
figure;
plot(id,north,'b')
title('NORTH-COORDINATE TIME SERIES', 'FontSize',12)
xlabel('SESSIONS', 'FontSize',10)
ylabel('NORTH', 'FontSize',10)
set(gca, 'XTick',id, 'FontSize',7) % Specify XTick Values
This reduces the font size on all axes tick labels and everything else as well, so you have to set the title and axis labels individually, as I did here.
In R2014b, you can easily rotate the tick labels so they won’t overlap. If the tick labels are densely packed, you may want to plot every other one or every fifth one, for instance. If you have R2014a or earlier, you will have to specify the 'XTickLabel' values as a cell array of strings, and rotate them using the Text Properties command functions.
The easiest way to deal with densely packed tick labels is simply to display fewer of them.
Weitere Antworten (0)
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!