plotting two legends on the same plot
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Randy Chen
am 23 Nov. 2020
Bearbeitet: Ameer Hamza
am 23 Nov. 2020
I have trouble plotting two legends for two lines on the same plot . Here are my codes:
p = linspace(0,1,50);
v = -290*9.8*log(0.15+0.85*p);
v2 = -370*9.8*log(0.25+0.75*p);
plot(p,v,'-r');
hold on
legend option1
p2 = plot(p,v2,'-b');
legend option2
hold off
xlabel('PI for two options')
ylabel('staging velocity(km/s)')
When I plot this, only legend option2 shows up. How should I change my codes?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/424778/image.jpeg)
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 23 Nov. 2020
Bearbeitet: Ameer Hamza
am 23 Nov. 2020
It is easier to first create the lines and then make a single call to legend()
p = linspace(0,1,50);
v = -290*9.8*log(0.15+0.85*p);
v2 = -370*9.8*log(0.25+0.75*p);
plot(p,v,'-r');
hold on
p2 = plot(p,v2,'-b');
legend({'option1', 'option2'})
hold off
xlabel('PI for two options')
ylabel('staging velocity(km/s)')
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!