modifying the legend for multiple plots

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Sulaymon Eshkabilov
Sulaymon Eshkabilov il 6 Nov 2021
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 Commenti
MA
MA il 6 Nov 2021
thank you, that was a new idea for me thanks a lot.
Sulaymon Eshkabilov
Sulaymon Eshkabilov il 6 Nov 2021
Most welcome! All the best.

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by