How to cluster some of a 3d plot values

1 view (last 30 days)
Jad Diab
Jad Diab on 14 Nov 2020
Edited: Ameer Hamza on 14 Nov 2020
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..

Answers (1)

Ameer Hamza
Ameer Hamza on 14 Nov 2020
Edited: Ameer Hamza on 14 Nov 2020
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.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!