How to cluster some of a 3d plot values

1 次查看(过去 30 天)
Hello everyone, I am new here.
I am trying to do a 3d plot of the variation of solar radiation along one year.
In the y-z axis I have the solar radiation vs hours (1 to 24 hours) and on the x axis I am getting the days of the year on matlab (1 to 365).
My question is how can I cluser the days of the years on the x axis to have them per month? I don't want to change the axis, I want the same plot but instead of reading 1 to 365 on the x axis how can I change it to have January on the plot (that extends from day 1 to 30 on the same 3d plot), etc..

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-11-14
编辑:Ameer Hamza 2020-11-14
You can set the xticks and their labels as shown in following code
days = [0 31 28 31 30 31 30 31 31 30 31 30 31];
cum_days = cumsum(days);
xv = movmean(cum_days, 2, 'Endpoints', 'discard');
xticks(xv);
xticklabels({'January', 'February', 'March', 'April', 'May', 'June', ...
'July', 'August', 'September', 'October', 'November', 'December'})
It will place the labels at middle of each month. Note that you might also need to rotate the labels to display them properly. In that case, use
ax = gca;
ax.XTickLabelRotation = -45; % 45 is rotation angle in clockwise direction.

类别

Help CenterFile Exchange 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by