modifying the legend for multiple plots

1 回表示 (過去 30 日間)
MA
MA 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 Center および File ExchangeLegend についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by