Wrong coloring of legend in semilogx plot
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nora
el 30 de Oct. de 2014
Comentada: Nora
el 10 de Nov. de 2014
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145909/image.png)
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 comentarios
Chad Greene
el 30 de Oct. de 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?
Respuesta aceptada
Matt Tearle
el 30 de Oct. de 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)
Más respuestas (0)
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!