## How to create a legend with multiple plots?

### andrew (view profile)

on 7 Mar 2014
Latest activity Commented on by andrew

### andrew (view profile)

on 7 Mar 2014
The following code is what I used to plot my graphs
h1=plot(exp(Xs),exp(Yest),'-b','LineWidth',2);
hold on
h2=plot(exp(Xs),exp(YCI95s),'--r','LineWidth',2);
h3=plot(exp(Xs),exp(YCI90s),':c','LineWidth',2);
h4=plot(exp(Xs),exp(YCI75s),'--g','LineWidth',2);
h5=plot(exp(Xs),exp(YCI50s),':m','LineWidth',2);
h6= scatter(exp(data1.logAge),exp(data1.logRate),'x','k');
I was wondering if there is a way to make one legend for each plot. h2, h3, h4,h5, are confidence interval bands.

### Doug Hull (view profile)

Answer by Doug Hull

### Doug Hull (view profile)

on 7 Mar 2014

h(1) = plot(1:5, rand(1,5)+1)
hold on
h(2) = plot(1:5, rand(1,5)+2)
legend('alpha','bravo')
This is one legend for the different lines. I think it is not clear what you want. Is this it?

andrew

### andrew (view profile)

on 7 Mar 2014
This is my plot I have 2 lines with the same color, I'm wondering how to create a legend representing each line once.