How can I add month labels to the x-axis of my plot?
8 views (last 30 days)
Show older comments
I have a series of data (in excel) which contains a data point for every three hour period over a year. I have imported the data into MATLAB and want to plot the data and have labels on the x-axis displaying the month of the different sections of data. Unfortunately the 'Date' column in the excel file is not complete, with some gaps, and two years of data interspersed such that sections of the data during a 'month' were recorded in different years.
Sample Data:
12/01/1979 03:03:00 1.62 3.49
12/01/1979 06:07:00 1.76 3.14
09:00:00 1.395 3.44 *Missing date
12:00:00 1.395 3.44
12/01/1979 14:56:59 1.03 3.74
12/01/1979 18:01:00 0.78 5.12
12/01/1979 21:01:00 0.57 3.28
13/01/1979 00:03:00 0.47 2.99
13/01/1979 03:03:00 0.54 3.51
13/01/1979 06:07:00 0.61 3.23
13/01/1980 09:04:00 0.5 3.86 *Change of year
13/01/1980 12:03:59 0.53 4.05
For the above data, as an example, I would like to plot one of the final columns and display a label of 'January' below it.
Answers (1)
Naomi
on 1 May 2013
Edited: Naomi
on 1 May 2013
For labelling the ticks as months, I came up with:
set(gca, 'xtick', 1:13);
set(gca,'xticklabel', {[ blanks(25) 'Jan'], [ blanks(25) 'Feb'], [ blanks(25) 'Mar'],[ blanks(25) 'Apr'],[ blanks(25) 'May'], ... [ blanks(25) 'Jun'],[ blanks(25) 'Jul'], [ blanks(25) 'Aug'], [ blanks(25) 'Sep'], [ blanks(25) 'Oct'],[ blanks(25) 'Nov'], [ blanks(25) 'Dec'], ''});
You'll need to play with the number of blank spaces you need for your particular axis size ...
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!