I am trying to make a plot of four pairs of time series. The plot appears fine; I have two lines in each color as I want. The problem, in this case, is that the first two legend items both have red lines, and the second two both have black lines. I want each legend entry to match the color of the pair of lines on the plot. My code is below; I hope someone can help. Some comments on the code:(adsbygoogle = window.adsbygoogle || []).push({});

z is the counter - I have a loop that calculates the data and puts in into plotdata for each run. The four correspond to four values of p.

hold on

figure(1)

colors=['r' 'k' 'g' 'b'];

semilogy(plotdata(:,1),plotdata(:,2:3),colors(z))

xlabel('Time, {\itt}','FontSize',24,'FontName','Times New Roman')

ylabel('Fractional Population','FontSize',24,'FontName','Times New Roman')

set(gca,'FontSize',24,'FontName','Times New Roman')

grid on

legend(char({strcat('{\itp} =',num2str(p(1:z)'))}))

Thanks!

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab Legend Problem

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - Matlab Legend Problem | Date |
---|---|

How to program this in Matlab | Feb 28, 2018 |

Matlab Making a short test for self-adjointness | Feb 23, 2018 |

Matlab: Data from Best Fit Lines into Legend | Mar 13, 2012 |

Dynamic Legend in MatLab | Nov 28, 2011 |

Question about matlab figure legend. | Mar 5, 2009 |

**Physics Forums - The Fusion of Science and Community**