Matlab Legend Problem


by Old Guy
Tags: legend, matlab
Old Guy
Old Guy is offline
#1
Oct12-11, 09:21 AM
P: 97
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:

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!
Phys.Org News Partner Science news on Phys.org
Cougars' diverse diet helped them survive the Pleistocene mass extinction
Cyber risks can cause disruption on scale of 2008 crisis, study says
Mantis shrimp stronger than airplanes

Register to reply

Related Discussions
Legend, mathematica Math & Science Software 9
Question about matlab figure legend. Math & Science Software 2
What about an icon legend? Forum Feedback & Announcements 3
will you pass on the story to your son? General Discussion 6