Why is it referring to each seperate datapoint in the legend?
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kelly Thompson
am 30 Mai 2019
Beantwortet: Adam Danz
am 30 Mai 2019
So I am plotting two variables seperately on the same plot, in which each variable is a 26x23 matrix. So it plots 23 observations for each of the 26 features along the x-axis.
figure;
plot(acuteEdgeBC1, 'r*'); hold on;
plot(chronicEdgeBC1, 'bs');
legend('Acute', 'Chronic');
The plot looks fine apart from the legend, as it sees each datapoint from both plots as a seperate thing to note in the legend. So when I try making a legend the way I have done above, 'Acute' and 'Chronic' labels are both assigned to a red star. If I just specify that I want a legend without labels, it shows all the datapoints on the legend, as shown below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/222116/image.jpeg)
What I would like is a red star assigned to 'Acute' and a blue square assigned to 'Chronic'. How can I do this? Any help would be greatly appreciated- thanks!
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 30 Mai 2019
Always use object handles.
figure;
ph1 = plot(acuteEdgeBC1, 'r*'); hold on;
ph2 = plot(chronicEdgeBC1, 'bs');
legend([ph1(1),ph2(1)],'Acute', 'Chronic');
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!