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
回答(1 个)
dpb
2015-8-12
0 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Polar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!