Azzera filtri
Azzera filtri

How to add legend in CIE diagram

2 visualizzazioni (ultimi 30 giorni)
Md Tanvir Emrose
Md Tanvir Emrose il 19 Ott 2023
Commentato: Chunru il 19 Ott 2023
I have four points that I want to plot on CIE diagram. I am using the following command:
plotChromaticity
hold on
scatter([x_1 x_2 x_3 x_4],[y_1 y_2 y_3 y_4])
hold off
Now I want to add legend for these four points. For example: 'red', 'blue', 'green', and 'yellow'.
How can I do that?

Risposta accettata

Chunru
Chunru il 19 Ott 2023
Modificato: Chunru il 19 Ott 2023
plotChromaticity
hold on
x = rand(1,4);
y=rand(1,4);
name =["red", "blue", "green", "yellow"]
name = 1×4 string array
"red" "blue" "green" "yellow"
for i=1:length(x)
hs(i) = scatter(x(i), y(i), 'DisplayName', name(i));
end
hold off
legend(hs)
  2 Commenti
Md Tanvir Emrose
Md Tanvir Emrose il 19 Ott 2023
Modificato: Md Tanvir Emrose il 19 Ott 2023
Thank you so much. How can I remove data1 from the legend?
Chunru
Chunru il 19 Ott 2023
See the update above. Use handles of graphic objects.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by