change x axis in a plot

Hello everyone,
I would like to plot a graph vs the month names ('Jan' 'Feb' ... 'Dec'). I have in fact the solar power generation for a year in a vector (length = 5525600) and I tried with this:
h=plot(solar)
set(get(h,'Parent'),'XTickLabel',{'Jan' 'Feb' 'Mar' 'Apr''May' 'Jun' 'Jul' 'Aug' 'Sept' 'Oct' 'Nov' 'Dec'})
The problem is that all the months are not shown below the x axis. It stops at 'Jul'. Can someone help me with this please?
Thank you

Respuestas (1)

dpb
dpb el 12 de Ag. de 2015

0 votos

Convert the times to date numbers and plot against them (or compute from the sampling time the locations in the vector that are the beginning of month indices).
If use the former, then use datetick to format the axes labels as times and set the tick marks to the first day of the month (using the date number).
The reason the labels written above stopped at July is that there were seven tick marks by default; you have to set the number of ticks to the number that you want labels for and at those values, either in date numbers if use it or as indices into a linear array if that's the way you plot.

Categorías

Más información sobre Polar Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de Ag. de 2015

Respondida:

dpb
el 12 de Ag. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by