Wrong legend in plot

Hi all,
I am plotting in a logarithmic scale. I get the plot but when I add the legend its wrong.
semilogy(tT,PT005,'-',tT,PTo(1,:),'--',tT,PTo(2,:),'--',tT,PTo(3,:),'--',tT,PTo(4,:),'--',tT,PTo(5,:),'--',tT,PTo(6,:),'--',tT,PTo(7,:),'--',tT,PTo(8,:),'--',tT,PTo(9,:),'--',tT,PTo(10,:),'--',tT,PTo(11,:),'--')
legend('Uncontrolled','epsilon=0.01','epsilon=0.011','epsilon=0.012', 'epsilon=0.013','epsilon=0.014','epsilon=0.015','epsilon=0.016','epsilon=0.017','epsilon=0.018', 'epsilon=0.019', 'epsilon=0.020')
I have attached the MATLAB data that I am trying to plot here as well. How can I fix this problem?

Risposte (2)

Walter Roberson
Walter Roberson il 9 Set 2017

1 voto

Your tT is 7 x 101, so each tT, Y specification is asking to draw 7 lines.
Rik
Rik il 8 Set 2017

0 voti

Have you taken a look at the documentation? For example, you can add 'Location','northwest' to the end of your call to legend.

5 Commenti

JR
JR il 8 Set 2017
Unfortunately that is not the problem that I have. It's when I plot it, the legend doesnt give me the same colour as my plot.
Could you attach images and point out specific difficulties? When I test, I was not able to see any difference.
I used
h = semilogy(tT,PT005,'-',tT,PTo(1,:),'--',tT,PTo(2,:),'--',tT,PTo(3,:),'--',tT,PTo(4,:),'--',tT,PTo(5,:),'--',tT,PTo(6,:),'--',tT,PTo(7,:),'--',tT,PTo(8,:),'--',tT,PTo(9,:),'--',tT,PTo(10,:),'--',tT,PTo(11,:),'--');
and then assigned different markers to h(1), h(2) and so on, focusing on one at a time; in each case the colors appeared to match.
Note: you did not happen to post tT but as it is constant I just used
tT = linspace(1,50,101);
JR
JR il 8 Set 2017
Hello Walter. I have attached the image here along with the tT. How do I assign the h(1).. h(n)?
Which MATLAB release are you using, and which operating system? Your dashing is not even matching.
Experiment with
set(gcf, 'Renderer', 'painters')
and
set(gcf, 'Renderer', 'openGL')
JR
JR il 9 Set 2017
Im using windows 10 and the 2016b version. Is this a bug in MATLAB?

Accedi per commentare.

Tag

Richiesto:

JR
il 8 Set 2017

Risposto:

il 9 Set 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by