How to cluster some of a 3d plot values

조회 수: 2 (최근 30일)
Jad Diab
Jad Diab 2020년 11월 14일
편집: Ameer Hamza 2020년 11월 14일
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