How to Combine Legend Icons from Two Graphs
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I would like to show the correct legend for the "Alternative Fit". Please see code below (only last three lines of interest) and image attached and assist if possible.
figure
%Main fit graph
miniLP = scatter(n,xdiffm)
fitLP = fitlm(n,xdiffm)
f = plot(fitLP)
xlim([0 4])
hold on
m = 0.19029;
N = 4;
x = linspace(0,4,N);
y = 4.2614+m*(x);
g = plot(x,y,'r');
title(' ');
xlabel('Number of Minimum');
ylabel('x-distance in eV');
set(gca,'xtick',0:4);
%Alternative fit graph
fitLP2 = fitlm(n2,xdiffmI)
m2 = 0.072857;
x2 = linspace(0,4,N);
y2 = 4.6529+m2*x2;
k = plot(x2,y2,'--m')
%legends
legend(f, 'Data', 'Fit', 'Confidence bounds',) 'Alternate Fit'); %Would like to add this from k plot. I'm aware that the "Alternative Fit" shown in image is not referring to the correct legend icon
hold off
Thanks in advance.
1 Kommentar
VBBV
am 12 Okt. 2020
% if true
% code
% end
legend([f k],{'Data','fit','Confidence bounds','Alternate fit'});
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!