How do I divide the existing tick values on the x-axis

12 vues (au cours des 30 derniers jours)
Kevin Kuck
Kevin Kuck le 28 Avr 2020
Commenté : Ameer Hamza le 28 Avr 2020
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.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 28 Avr 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 commentaires
Kevin Kuck
Kevin Kuck le 28 Avr 2020
That worked!
Thank you so much for your help
Ameer Hamza
Ameer Hamza le 28 Avr 2020
I am glad to be of help.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by