How to extract tick label in sequence data
2 ビュー (過去 30 日間)
古いコメントを表示
I have irregular sequence data as:
2019/1/1 3:00:00, 1
2019/1/1 4:00:00, 2
2019/1/2 3:00:00, 3
2019/1/2 5:00:00, 4
2019/1/2 6:00:00, 5
2019/1/2 7:00:00, 6
2019/1/3 2:00:00, 7
2019/1/3 3:00:00, 8
2019/1/3 4:00:00, 9
2019/1/4 3:00:00, 10
2019/1/4 4:00:00, 11
2019/1/5 1:00:00, 12
2019/1/5 3:00:00, 13
and I want to extract the following tick labels and their position when I plot the data
position label
1 1/1
3 1/2
7 1/3
10 1/4
12 1/5
0 件のコメント
採用された回答
Cris LaPierre
2021 年 1 月 13 日
What do you mean you want to extract them? Do you mean set them?
x = linspace(0,10);
y = x.^2;
plot(x,y)
xticks([0 5 10])
xticklabels(["x = 0","x = 5","x = 10"])
2 件のコメント
Cris LaPierre
2021 年 1 月 13 日
In fact, I just want to find the first position of each day in my example data.
This would be good information to include in the orginal question.
data = readtable("datesVals.csv","Format",'%{yyyy/MM/dd HH:mm:ss}D %f')
tDays = groupsummary(data,"Var1","day",'min',"Var1")
plot(data.Var1,data.Var2)
xticks(tDays.min_Var1);
xticklabels("1/" + num2str(day(tDays.min_Var1)))
その他の回答 (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!