MATLAB: Legend error. How to fix

legendplot

I used the below code and got error with the legend as in the figure. Can someone please help fix?
fig = figure(1);
ax = axes(fig);
xlabel('\xi');
ylabel(' \Omega(\xi,\tau)');
title('Varying injection rates vs fracture width');
hold on
legend('\alpha=0,k-','\alpha=1/9,b-','\alpha=1/10,r-','location', 'northeast')
h1 = openfig('widthchange.fig','reuse');
h2 = openfig('widthconstant.fig','reuse');
h3 = openfig('widthchange2.fig','reuse');
copyobj(h1.Children.Children,ax);
copyobj(h2.Children.Children,ax);
copyobj(h3.Children.Children,ax);
close(h1);
close(h2);
close(h3);

Best Answer

Move this line to end, after copying the line objects.
legend('\alpha=0','\alpha=1/9','\alpha=1/10','location', 'northeast')
Also, it looks like each line is represented twice since your legend contains two lines for each color. Examine the outputs of h1 h2 h3 to see if there is more than 1 handle in each.
If so, and if the lines are identical, use,
legend([h1(1),h2(1),h3(1)], '\alpha=0','\alpha=1/9','\alpha=1/10','location', 'northeast')