I made a line plot of a 30x1 matrix. Of course the values on the x-axis are 1-30 but I need to add 1970 to each of those because the axis is supposed to represent a year. Is there a way to add 1970 to each of the x-axis values? Thanks in advance.

1 comentario

Michaela Wood
Michaela Wood el 27 de Abr. de 2018
I tried
set(gca, 'XTickLabel',1970:2000)
which changed the axis to 1970-1976 instead of 1970-2000.

Iniciar sesión para comentar.

 Respuesta aceptada

Star Strider
Star Strider el 27 de Abr. de 2018

0 votos

One approach:
x = ...;
y = ...;
figure(1)
plot(x, y)
grid
xt = get(gca, 'XTick');
xtl = linspace(1970, 2000, numel(xt));
set(gca, 'XTick',xt, 'XTickLabel',xtl)

2 comentarios

Michaela Wood
Michaela Wood el 27 de Abr. de 2018
Thank you!
Star Strider
Star Strider el 27 de Abr. de 2018
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Objects en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Abr. de 2018

Comentada:

el 27 de Abr. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by