How to set the number of x-axis ticks on a datetime plot?
Mostrar comentarios más antiguos
If I plot a variable y at times given by a datetime vector t, the x-axis ticks are automatically chosen,
t = [datetime('now'):1/12:datetime('tomorrow')]; % Example datetime vector
y = rand(size(t)); % Some time dependent variable to plot
plot(t, y); % x-axis ticks every 2 hours
How can I specify the number of ticks, as is done in the very useful program axdate? I don't want to say "make ticks every xx minutes", instead I would like to say "make about 20 xticks" because while I don't always know the tick interval I want, I may know 20 tick labels are easy to read. I say "about 5 ticks" because I would like the resulting tick spacing to be some human-readable interval, such as 1 minute instead of 53 seconds, like in axdate.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Grid Lines, Tick Values, and Labels en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!