How can I add month labels to the x-axis of my plot?

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.

댓글 수: 2

Just one label?
Ben
Ben 2013년 2월 27일
I would like to be able to have all the months plotted on the same graph, as a year long sequence (as opposed to a line for each month) and have the name of the month display below the relevant section of data. Instead of having tick marks for the length along the vector, I would like a tick mark to denote the start/end of each month, with the month name in between.

댓글을 달려면 로그인하십시오.

답변 (1개)

Naomi
Naomi 2013년 5월 1일
편집: Naomi 2013년 5월 1일

0 개 추천

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 ...

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

태그

질문:

Ben
2013년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by