Most constrasting colormap for multi-line plots

173 views (last 30 days)
Hi everyone
I'm having a very frustrating time trying to get constrating colormaps for multiline plots.
For people with poor eyesight like me, it's very hard to tell the difference between the lines.
Here's an example using a very boring default scheme
x = linspace(0,1,101);
y(1,:) = x.^2;
y(2,:) = x.^2.2;
y(3,:) = x.^2.4;
h = plot(x,y)
Colors = get(h,'Color');
Colors{:}
What I'd really like, ideally, is an algorithm that delivers, for given n, a list of n colors that will have in some sense maximum pairwise contrast between colors. Doubt if this is possible, but any recommendations for something better than what I have would be most appreciated
Thanks for any advise
  2 Comments
Jana
Jana on 18 Jan 2014
Hi guys, My question may seem stupid, but how do I set ANY colortable to this kind of plot? I have a matrix which I plot in lines (like the example of Bjorn). I keep failing in set ANY different colortable - probably one of the default ones would do. Thanks a lot for an answer. Jana
Image Analyst
Image Analyst on 18 Jan 2014
Did you see my color order demo I attached in my answer? Wouldn't that do what you want?

Sign in to comment.

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 19 Dec 2013
(Always search the file exchange before doing any work of your own, and way before asking others)
HTH
  1 Comment
Leo Simon
Leo Simon on 21 Dec 2013
Thanks very much Bjorn. For the record, I did actually search quite hard to find an answer, but I'm afraid the search terms beautiful, distinguishable, distinct didn't occur to me!

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 21 Dec 2013
Did you look at the colormap function in the help? The "lines" colormap is the built in colormap with the highest contrast between colors.
  2 Comments
Leo Simon
Leo Simon on 21 Dec 2013
Thanks for this, I didn't know about this option of colormap! To clarify, the relevant help command is
help lines,
not
help colormap.
The option unfortunately is not well documented under colormap, if mathworks happens to be listening.
I also don't feel for my taste that it works as well as distinguishable_colors, see the attached: the first uses the lines command, the second uses distinguishable_colors. Would be curious to learn if others agree or disagree!
Image Analyst
Image Analyst on 21 Dec 2013
Edited: Image Analyst on 21 Dec 2013
If you had used the full documentation with "doc colormap" instead of the limited command window version of it with "help colormap" you would have seen the built in colormaps as little pictures. Of course you're free to use whatever colormap you want, just make up something custom in a Nx3 2D array with values between 0 and 1, and use it.
plot(x,y, 'Color', myCustomColorMap(colorIndex, :));
You may also want to change the default color order. In that case, see my attached demo.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!