How to differentiate 2 overlapping lines in matlab by
21 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens

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');
0 commentaires
Réponses (1)
Walter Roberson
le 7 Avr 2018
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 commentaires
Walter Roberson
le 7 Avr 2018
lh = plot(x,y);
set(lh(1), 'Linestyle', '--');
set(lh(2), 'Linestyle', ':');
set(lh(3), 'Linestyle', '-.');
set(lh(4), 'Linestyle', 'none', 'Marker', 'v')
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
