Combining linestyle in legend.
12 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Image Analyst
on 16 Jun 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)"?
0 Comments
See Also
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!