Graph Legend not picking up third plot marker
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I've created a graph and tired to add in a legend to describe what each plot is however, MATLAB doesn't seem to be picking up the symbol for 'Toe off', it should be the red square. Does anyone know how to fix this issue? I've attached a screenshot of the code and the graph produced.
Thanks
0 Kommentare
Antworten (2)
Star Strider
am 8 Apr. 2021
It is likely not possible to determine what the problem is without the actual data and relevant code.
In their absence, try this:
figure
hp{1} = plot(time, ankle_V);
hold on
hp{2} = plot(time(ankle_HS_V), zeros(size(ankle_HS_V)), 'g*');
hp{3} = plot(time(ankle_TO_V), zeros(size(ankle_TO_V)), 'rs');
hold off
legend([hp{:}],'Ankle Velocity', 'Heel Strike', 'Toe Off')
See if that does what you want.
0 Kommentare
Adam Danz
am 8 Apr. 2021
There are multiple objects with the green asterisk and they are higher up in the uistack than the red squares. Since you're providing only 3 legend strings, the legend is choosing the first 3 items in the uistack which, apparently, are the blue line and the first two green astersks.
Instead use the DisplayName property to assign legend strings and then specify which object handles should appear in the legend
0 Kommentare
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!