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

8 visualizaciones (últimos 30 días)
Ben
Ben el 27 de Feb. de 2013
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 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 27 de Feb. de 2013
Just one label?
Ben
Ben el 27 de Feb. de 2013
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.

Iniciar sesión para comentar.

Respuestas (1)

Naomi
Naomi el 1 de Mayo de 2013
Editada: Naomi el 1 de Mayo de 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 ...

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by