tim
tim

Reputation: 10176

MATLAB: Make plotted lines distinguishable maximally

Do you know a way to somehow make plotted lines in MATLAB distinguishable at the maximum? I know about generating maximal distinguishable colors via this nice function from the file exchange but if the lines are very close together like in the following, it's still very tough to distinguish them. Probably not possible other then scaling the axis logarithmically, is it!?

enter image description here

Edit: Image URL for a better view: https://i.sstatic.net/JIF1E.png

Upvotes: 1

Views: 778

Answers (2)

A simple function to implement Luis Mendo's suggestion:

function out = interleaveFuncs(len,varargin)
% input lines must be column vectors, so they would be plotted correctly
% each input can contain more than one column (line) though
out = cat(2,varargin{:});
sz = size(out);
out(sub2ind(sz, 1:sz(1) ,mod(floor([0:sz(1)-1]/len),len)+1)) = nan;

Use like this:

a=[1:10].';
plot(a,interleaveFuncs(3,[a a+1],a+2));

Upvotes: 3

Luis Mendo
Luis Mendo

Reputation: 112659

In addition to color, you can distinguish the lines by marker type ('o', '.', ...) and line type ('-', '--', ...). For example:

plot(x1,y1,'o--','color',color1)
plot(x2,y2,'+-.','color',color2)

Another possibility (as indicated in the comments): you could apply some "gating" to the functions: for example, y1.*[1 1 1 NaN NaN NaN 1 1 1 ...], y2.*[NaN NaN NaN 1 1 1 NaN NaN NaN...]. You will get color-striped lines, each with a hole where the other is visible.

Upvotes: 2

Related Questions