Combining linestyle in legend.
Mostrar comentarios más antiguos
Hi, I have a code that produce the following figure:

As a minimal example:
f1=rand(1,100);
f2=rand(1,100);
f3=rand(1,100);
f4=rand(1,100);
figure;
plot(x,f1,'b',x,f2,'b:',x,f3,'r',x,f4,'r:')
legend('Horizontal chain','','Diagonal chain','')
I would like to clarify that each string of text designate each color of the plot by putting the text in the middle of 2 entry of legend or by combining the 2 linestyle in one like so :

But I couldn't find any way to do this. Thank you for your help.
Respuestas (1)
Image Analyst
el 16 de Jun. de 2018
1 voto
I think you'd have to find the legend's lines' locations with findobj(), and use fill() or patch() exactly where you want the gray patch (to cover up existing line), and use plot() to draw a line at the new line location- could be tricky.
How about just using appropriate working, like "Horizontal Chain (Lower Limit)" and "Horizontal Chain (Upper Limit)"?
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!