Wrong coloring of legend in semilogx plot
6 views (last 30 days)
Show older comments

I realized in both 2013a and 2013b that there seems to be a bug in the coloring in the semilogx function. Colors displayed in the legend are not even present in the plot itself and sometimes the order seems to be wrong. In any case it's not possible to say which color refers to which data. I tried solving this problem for some days now and I'm pretty desperate about it. It's the same result whether I call the function from a .m-file or directly from the command window. Any work around? That's the code I use
figure(3)
semilogx(f20,real(var20(:,8)), f40,real(var40(:,8)), f60, real(var60(:,8)),f80, real(var80(:,8)), f100, real(var100(:,8)))
legend('20','40','60', '80', '100')
The attached picture shows the disaster.
Thanks for your help!
2 Comments
Chad Greene
on 30 Oct 2014
Can you give us your f20, etc data, or make some up?
Does the same problem happen if you use plot instead of semilogx?
Accepted Answer
Matt Tearle
on 30 Oct 2014
I just tried an example in R2013b and it worked fine, but then I messed with it a bit and happened to get something very similar to what you're seeing. So try looking at the dimensions of your x variables, f60 in particular.
whos f*
When I used a matrix for one of the x variables, it got messed up. Perhaps f60 is a matrix instead of a vector?
If that's not the issue, is there any way you can share your variables with us? (Or, at very least, size/type/etc)
More Answers (0)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!