MATLAB Answers

A simple question regarding axes label

2 views (last 30 days)
Fred
Fred on 27 Dec 2012
I am plotting a time series 12 months*10 years=120 values and my default x axis label is from 1 to 120 but I want change the label of first month of each year: 1 to 2000, 13 to 2001, 25 to 2002 and so on. I know it has to do with Ticks, but I dont know how to write the code Thanks

  0 Comments

Sign in to comment.

Accepted Answer

Wayne King
Wayne King on 27 Dec 2012
Edited: Wayne King on 27 Dec 2012
You can first set up the xticks to match exactly the beginning of the years and then set the xticklabel property to match the years
x = randn(120,1);
plot(x)
set(gca,'xtick',1:13:120);
set(gca,'xticklabel',2000:2009);

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products


Translated by