Combining linestyle in legend.

12 vues (au cours des 30 derniers jours)
jojogoo31
jojogoo31 le 16 Juin 2018
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.

Réponses (1)

Image Analyst
Image Analyst le 16 Juin 2018
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)"?

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by