Reputation: 10176
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!?
Edit: Image URL for a better view: https://i.sstatic.net/JIF1E.png
Upvotes: 1
Views: 778
Reputation: 973
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
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