setting y axis data in figure

1 回表示 (過去 30 日間)
sermet
sermet 2015 年 9 月 17 日
コメント済み: sermet 2015 年 9 月 17 日
time=[0:2:24];
data=[23.3;21.68;27.47;41.98;60.13;76.10;75.13;66.050;54.027;32.78;24.62;22.67;23.38];
figure;
plot(time,data,'r','LineWidth',2)
title('station','fontsize',12,'fontweight','bold')
xlabel('UTC','fontsize',12,'fontweight','bold')
ylabel('data','fontsize',12,'fontweight','bold')
set(gca, 'XTick',time, 'FontSize',12); grid on
%in y axis of figure, I need to see all data values w.r.t. time. Like, 23.3 for 0, 21.68 for 2 hours, etc. I also need to narrow the data space of the y axis. i.e, in this plot, increment of data is 10, can I set 5 something?

採用された回答

@Johannes
@Johannes 2015 年 9 月 17 日
Hi, to narrow the data space you can use the following commands,
ax=gca;
ax.YLim = [20 78];
ax.YTick = 20:2:78;
ax.Ylim is setting the limits of the y-axis and ax.YTick sets the distance between the Ticks.
To display the data values you could use the text function.
text(x,y,str)
Bye, john
  2 件のコメント
sermet
sermet 2015 年 9 月 17 日
hi, I used your command but it gives me this warning;
Warning: Struct field assignment overwrites a value with class "double". See MATLAB R14SP2 Release Notes, Assigning Nonstructure Variables As Structures Displays Warning, for details.
And there is no changes happened.
sermet
sermet 2015 年 9 月 17 日
I understood that it was related the version issue. Your codes work right, thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by