Legend not matching the data
6 views (last 30 days)
Show older comments
Herline van der Spuy
on 18 Oct 2021
Commented: Star Strider
on 18 Oct 2021
I have weird data and not enough time to figure out the for loop stuff, so I did a basic plotting thing. But the legend is not matching my data. Is it the size of the legend or something?
j1 = plot(temp2412,original2412(:,1),'-o','Color',C6,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C6,'MarkerFaceColor',C6);
hold on
j2 = plot(temp2412,original2412(:,2),'-o','Color',C1,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C1,'MarkerFaceColor',C1);
j3 = plot(temp2412,original2412(:,3),'-o','Color',C3,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C3,'MarkerFaceColor',C3);
j4 = plot(temp3624,original3624(:,1),'-o','Color',C8,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C8,'MarkerFaceColor',C8);
j5 = plot(temp3018,original3018(:,1),'-o','Color',C10,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C10,'MarkerFaceColor',C10);
j6 = plot(temp2412,aged2412(:,1),'--o','Color',C6,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C6,'MarkerFaceColor',C6);
j7 = plot(temp2412,aged2412(:,2),'--o','Color',C1,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C1,'MarkerFaceColor',C1);
j8 = plot(temp2412,aged2412(:,3),'--o','Color',C3,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C3,'MarkerFaceColor',C3);
j9 = plot(temp3624,aged3624(:,1),'--o','Color',C8,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C8,'MarkerFaceColor',C8);
j10 = plot(temp3624,aged3624(:,2),'--o','Color',C10,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C10,'MarkerFaceColor',C10);
leg = [j1,j2,j3,j4,j5,j6,j7,j8,j9,j10];
xlim([-40 -6])
ylim([0 700]);
xlabel('Temperature (°C)','FontSize',fontsize);
ylabel('Stiffness (MPa)','FontSize',fontsize);
set(gca,'fontsize',22);
grid on
ax = gca;
legend(leg,'PEN 70/100 O','S-E1 O','S-E2 O','S-R1 O','S-R2 O','PEN 70/100 A','S-E1 A','S-E2 A','S-R1 A','S-R2 A');
0 Comments
Accepted Answer
Star Strider
on 18 Oct 2021
It is possible to label the individual plots in the plot calls.
.
2 Comments
Star Strider
on 18 Oct 2021
Example —
x = 1:10;
y = rand(3,10);
figure
plot(x, y)
legend('Row 1','Row 2','Row 3', 'Location','NE')
figure
plot(x, y)
hleg = legend('Row 1','Row 2','Row 3', 'Location','NE');
lgdpos = hleg.Position;
hleg.Position = lgdpos+[-0.3 -0.25 0.3 0.25];
hleg.FontSize = 12;
Experiment with the other properties (if necessary) to get the desired result.
.
More Answers (0)
See Also
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!