How to differentiate 2 overlapping lines in matlab by

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)

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

i put '--' in the plot line but im still getting something like this.
Use a mix, not just the same line style for each. And experiment with combinations.
im sorry, im new to matlab, can i have an example code? Thank you.
lh = plot(x,y);
set(lh(1), 'Linestyle', '--');
set(lh(2), 'Linestyle', ':');
set(lh(3), 'Linestyle', '-.');
set(lh(4), 'Linestyle', 'none', 'Marker', 'v')

Accedi per commentare.

Categorie

Tag

Richiesto:

il 7 Apr 2018

Community Treasure Hunt

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

Start Hunting!

Translated by