modifying the legend for multiple plots

조회 수: 1 (최근 30일)
MA
MA 2021년 11월 6일
댓글: Sulaymon Eshkabilov 2021년 11월 6일
i am trying to plot som data that is divided into bins according to a time interval of 3 hours. i.e the first plot represent the data from 0:00am to 3:00 am and so on .
I would like to have the legend on each plot to display the interval of time that we are plotting. i.e instead of having 1,2,3.. displayed on each legend representing the bin number, we want to have the time interval of each bin ex: 0:00am- 3:00am, 3:00am - 6:00am and so on. how may we do that?
I attach a sample of how the plots looks like and the code I am using to generate them.

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 6일
You should introduce a new cell variable with legend names as you specified, e.g.:
TimeInterval = [{'0:00am- 3:00am'}, {'3:00am- 6:00am'}, {'6:00am- 9:00am'}, {'9:00am- 12:00pm'},...
{'12:00pm- 3:00pm'}, {'3:00am- 6:00pm'}];
uBin=unique(t1.Bin);
for i=uBin(:).'
nexttile
isBin=(t1.Bin==i);
scatter(t1.NE8(isBin),t1.GDALT(isBin),'.')
legend("Bin "+ TimeInterval{i}, 'Location','best')
xlabel('NE, units'),ylabel('GDALT, ft')
box on
xlim([0 3E12]);
ylim([100 2000]);
end
  댓글 수: 2
MA
MA 2021년 11월 6일
thank you, that was a new idea for me thanks a lot.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 6일
Most welcome! All the best.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by