writing all numbers on x axes with plot function

49 ビュー (過去 30 日間)
sermet
sermet 2014 年 11 月 22 日
コメント済み: Star Strider 2014 年 11 月 22 日
%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.

採用された回答

Star Strider
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 件のコメント
sermet
sermet 2014 年 11 月 22 日
I applied it but sometimes id numbers are quite high like (200-150) then it doesn't seem properly on the x axes in the figure. Is this a way that all numbers are visible even they are too many.
Star Strider
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 ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by