How to identify which lines in the plot correspond to which legend entry?
13 views (last 30 days)
Show older comments
Waseem Akhtar
on 1 Sep 2021
Commented: Waseem Akhtar
on 1 Sep 2021
Hi,
I have a figure with multiple lines and legend entries as attached figure. Since the colours of lines are repeating several times, it's difficult to identify which line of graph corresponds to which legend.
Suggest an easy solution, please.
Thanks
1 Comment
Mathieu NOE
on 1 Sep 2021
Well
do we really need to see all those horizontal lines ? does it bring any valuable info ?
I am not sure, but I guess we could plot the data differently.
as there is no y variation we could simply plot the y mean values versus the z data (that appears for the time being in the legend)
so at the end we would simply have a 2D plot of mean(y) vs z and no need for this huge legend
Accepted Answer
Walter Roberson
on 1 Sep 2021
Edited: Walter Roberson
on 1 Sep 2021
ax = gca;
set(ax.Children(1:7:end),'Marker', '.')
set(ax.Children(2:6:end),'Marker', 'v')
set(ax.Children(1:6:end),'Marker', '^')
set(ax.Children(2:6:end),'Marker', 'v')
set(ax.Children(3:6:end),'Marker', '<')
set(ax.Children(4:6:end),'Marker', '<')
set(ax.Children(5:6:end),'Marker', '*')
set(ax.Children(6:6:end),'Marker', '+')
xlim auto
ylim auto
and now you will want to zoom in to different areas (the xlim and ylim you have in effect is only the last segment of some of the lines.)
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!