Can't add more x-axis ticks or number of x-axis elements displayed.

2 views (last 30 days)
TimeCol=datenum(Sheet.Time);
TimeCol=Sheet1.Time/(24*3600);
TimeCol=datevec(TimeCol);
TimeCol=datetime(TimeCol);
plot(TimeCol,Value)
This results in an x-axis from 07:00 to 09:00 (hh:mm) in increments of 00:30, and I can't find a way to either add ticks every 15 minutes nor change the number of times displayed.

Accepted Answer

Voss
Voss on 24 Aug 2023
First, I'll try to reproduce something like your plot:
TimeCol=datetime(datevec(now()+seconds(1800*(0:4))));
Value = rand(1,5);
figure
plot(TimeCol,Value)
Now, I'll plot the same thing, but I'll adjust the x-ticks by setting the increment to 15 minutes:
figure
plot(TimeCol,Value)
xt = xticks();
xt = xt(1):duration(minutes(15)):xt(end);
xticks(xt);
Another identical plot, but this time specify that there must be 10 x-ticks:
figure
plot(TimeCol,Value)
xt = xticks();
xt = linspace(xt(1),xt(end),10);
xticks(xt);

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!