writing all numbers on x axes with plot function
38 次查看(过去 30 天)
显示 更早的评论
%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 个评论
采纳的回答
Star Strider
2014-11-22
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 个评论
Star Strider
2014-11-22
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!