How to differentiate 2 overlapping lines in matlab by
Mostra commenti meno recenti

There are 4 graphs here, each with their own color. However, the first line on the left is common between all 4 graphs. So is there a way to recolor just that portion with the mixture of all 4 chosen legend colours to show this is a common part of all 4 graphs?
What i have:
plot(x,y);
xlabel('x');
ylabel('y');
ylim([0,inf]);
title('Trajectory: X vs Y');
hold on;
legend('k=0','k=0.0005','k=0.001','k=0.0015');
Risposte (1)
Walter Roberson
il 7 Apr 2018
0 voti
There is no way to do it automatically.
You should consider experimenting with a mix of line styles and marker styles. Avoid the - line style on top, but -- and -: can leave gaps where the others can show through, and some of the marker shapes do not completely hide others of the shapes.
If you want one line with multiple colors then there are a couple of File Exchange contributions that can take care of that, one of which works using a surface() object and another uses a patch() object.
4 Commenti
Preets12
il 7 Apr 2018
Walter Roberson
il 7 Apr 2018
Use a mix, not just the same line style for each. And experiment with combinations.
Preets12
il 7 Apr 2018
Walter Roberson
il 7 Apr 2018
lh = plot(x,y);
set(lh(1), 'Linestyle', '--');
set(lh(2), 'Linestyle', ':');
set(lh(3), 'Linestyle', '-.');
set(lh(4), 'Linestyle', 'none', 'Marker', 'v')
Categorie
Scopri di più su Line Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
