How to manipulate xtick labels?

3 ビュー (過去 30 日間)
Ashfaq Ahmed
Ashfaq Ahmed 2022 年 7 月 17 日
回答済み: Chunru 2022 年 7 月 18 日
Hi!
I am plotting a simple data set, say -
plot(1:21,1:21);
Now, obviously the x axis will show 1 to 21. But I want to change it to year 1984 to 2021 (with proper space gap in the x axis). How can I do it?
  2 件のコメント
Chunru
Chunru 2022 年 7 月 18 日
What you mean by changing into year 1984 to 2021 from 1:21? Show an example.
Ashfaq Ahmed
Ashfaq Ahmed 2022 年 7 月 18 日
I am using this code to plot x axis ticks
Year_List = {'1984'; '1986';'1988';'1990';'1992';'1994';'1996';'1998';...
'2000';'2002';'2004';'2006';'2008';'2010';'2012';'2014';'2016';'2018';'2020'};
Gaps = [1:1:19];
xticks(Gaps);
xticklabels(Year_List);

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

回答 (1 件)

Chunru
Chunru 2022 年 7 月 18 日
What else do you need in addition to the following?
plot(1:21,1:21);
Year_List = {'1984'; '1986';'1988';'1990';'1992';'1994';'1996';'1998';...
'2000';'2002';'2004';'2006';'2008';'2010';'2012';'2014';'2016';'2018';'2020'};
Gaps = [1:1:19];
xticks(Gaps);
xticklabels(Year_List);
set(gca, 'FontSize', 8);
grid on

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by