Name legend on graph with a second y axis
Show older comments
I am plotting three curves on the same figure, but I have not been able to name the third legend because the third curve is plotted against a second y axis. In the following code is the graph and the things I've tried
T_4340_ASM = [ 205
315
425
540
650]
S_u_4340_ASM = [ 1980
1760
1500
1240
1020]
S_y_4340_ASM = [ 1860
1620
1365
1160
860]
El_4340_ASM = [ 11
12
14
17
20]
HB_4340_ASM = [ 520
490
440
360
290]
figure(1)
plot(T_4340_ASM,S_y_4340_ASM,"Marker","square",Color=[0.6350 0.0780 0.1840])
hold on
plot(T_4340_ASM,S_u_4340_ASM,"Marker","pentagram","Color",[0 0.4470 0.7410])
hold on
title('Tempering temperature vs 4340 Steel Mechanical properties')
xlabel('Temperature[C°]')
ylabel('[MPa]')
legend('Yield Point','Tensile Strength') %If I put a third entry on here it ignores it because at this point the other curve is not plotted yet
yyaxis right
plot(T_4340_ASM,El_4340_ASM,"Marker","o") %And if i put it after here it just names the last legend
ylabel('Elongation [%]')
Accepted Answer
More Answers (0)
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
