Borrar filtros
Borrar filtros

How to set start date in line plot?

1 visualización (últimos 30 días)
peterhack
peterhack el 12 de Nov. de 2016
Comentada: dpb el 13 de Nov. de 2016
Hi,
I was wondering how to set the start date of the plot to be march for example.
t = datetime(2013,01,01):calmonths(1):datetime(2013,12,31);
[y,m,d] = ymd(t);
x = month(t,'shortname');
h = datetime(x,'Format','MMM');
z = rand(1,12);
plot(t,z,'DatetimeTickFormat','MMM')
Thanks!

Respuesta aceptada

dpb
dpb el 12 de Nov. de 2016
xl=xlim; % retrieve current limits
xlim([datetime(2013,03,01) xl(2)]) % set beginning x-limit to 3/1/2013, keep end as is
Salt to suit...
  2 comentarios
peterhack
peterhack el 12 de Nov. de 2016
Any way to get rid of the single 2013 in the plot?
dpb
dpb el 13 de Nov. de 2016
???? No idea what you mean?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by