How to extract tick label in sequence data
2 views (last 30 days)
Show older comments
suling yin
on 13 Jan 2021
Commented: Cris LaPierre
on 13 Jan 2021
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 Comments
Accepted Answer
Cris LaPierre
on 13 Jan 2021
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 Comments
Cris LaPierre
on 13 Jan 2021
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)))
More Answers (0)
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!