How to show plot in interval of 3?

2 ビュー (過去 30 日間)
Ara
Ara 2022 年 7 月 23 日
コメント済み: Sam Chak 2022 年 7 月 23 日
Dear All,
How to write x axis to show 0-24 Local time in terval of 3? I would like to show in figure 0,3,6,9,...,24.
Best,
Ara

採用された回答

Sam Chak
Sam Chak 2022 年 7 月 23 日
編集済み: Sam Chak 2022 年 7 月 23 日
Hi @Ara
Here is an example to use ax.XTick:
x = linspace(0, 24, 2401);
y = 30*(sin(2*pi/24*x) + 1);
plot(x, y, 'linewidth', 1.5), grid on, xlabel('t, [Hours]')
ax = gca;
ax.XTick = 0:3:24;
ax.YTick = 0:10:60;
  1 件のコメント
Sam Chak
Sam Chak 2022 年 7 月 23 日
You are welcome, @Ara. I have modified the code to include the ax.YTick as well. If you find the example and MATLAB code are helpful, please consider accepting ✔ and voting 👍 the Answer. Thanks!

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

その他の回答 (1 件)

Ara
Ara 2022 年 7 月 23 日
Thank you. How about Y axis? I want to change it to YTick=0:10:60.

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by