How do I divide the existing tick values on the x-axis
10 views (last 30 days)
Show older comments
I'm trying to create a graph where the x-axis is made up of a 1x144 list of 10 minute intervals
ex: [10,20,30,40,50,...,1440]
The y-axis is made up of temperatures found at each 10 minute interval
x = time_10(1:144);
y = temp_out(1:144);
plot(x,y, '-', 'linewidth', 2)
However on the graph it breaks the x-axis up by intervals of 500 and displays: 0,500,1000,1500.
When I changed the ticks to display the x-axis in 60 min intervals from 0:1440. It looked too cluttered.
xticks(0:60:1440)
Is there someway I can divide each tick by 60 so the x-axis would appear clearer and be in terms of 1 hour intervals over 24 hours?
I tried changing the range of the x-axis, but that gave me a "vectors must be same length" error:
x = (1:24);
I've also tried:
xticks(0:60/60:1440)
xticks(0:60:1440/60)
xticks((0:60:1440)/60)
But quickly found it just ticked every minute or only the first 24 minutes.
0 Comments
Accepted Answer
Ameer Hamza
on 28 Apr 2020
Adding all the hours on the y-axis will look cluttered. I suggest that you use minor ticks to indicate hours and only display label values after interval of 3 hours. For example
x = time_10(1:144);
y = temp_out(1:144);
figure;
ax = axes();
plot(x,y, '-', 'linewidth', 2)
xticks(0:180:1440);
ax.XAxis.MinorTick = 'on';
ax.XAxis.MinorTickValues = 0:60:1440;
4 Comments
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!