4
$\begingroup$

Is there a better color scheme to make the lines and legends boxes more contranst?
I'm using ColorData[97] but there are some colors that look similar so I'm looking for a better color scheme.
As you can see from the image below pairs 6, 16, 1,7, 9,14 look similar.

enter image description here

*colors = ColorData[97] /@ Range[24];
list = {{"a"}, {"b", "c"}, {"d"}, {"e"}, {"f"}, {"g"}, {"h", 
    "k"}, {"l"}, {"m"}, {"n"}, {"p", "q", 
    "k"}, {"x"}, {"y"}, {"z"}, {"kh"}, {"xy"}, {"cy"}, {"cz"}};
linelegend = 
  LineLegend[{Opacity[opacity, Gray], 
    Directive[Red, Thickness[0.01], Dashed], White}, 
   Style[#, 30, Bold, Black] & /@ {"mnk", "htk", "kn"}, 
   "LegendItem" -> {"Square", Automatic, "Square"}, 
   LegendMarkerSize -> 25];
opacity = 0.2;
Dynamic[Legended[
  Row[{Plot[{x^2 - 1, 2 x - 3, 5 - 3 x, 5 x - 2 x^2, x^2/3, x^2/3 - 2,
       x^2/3 - 6, 2 x^2 - 1, 2 /3 x - 3, 1 - 3 x, 5/4 x - 2 , x^2 - 9,
       5 x^2/3, 8 x^2/3 - 2, 9 x^2/3 - 6, 1/(2 x), 1/(x - 1), x^2/(
      x - 3), 5 - 1/(3 x + 1), x^3/(6 x^2 + 3), x^5/(6 x - 3), 1/(
      x^2 + 9), 1/(8 - x), 1/(1 - 5 x)}, {x, 0, 6}, 
     GridLines -> Automatic, 
     PlotStyle -> 
      ReplacePart[
       Directive[#, Thickness[0.005]] & /@ 
        colors, {Except[Alternatives @@ n]} -> 
        Directive[Opacity[.01], Gray]], Ticks -> Automatic, 
     Frame -> True, Axes -> True, PlotStyle -> Thickness[0.5], 
     PlotRange -> {{0, 6}, {0, 6}}, 
     FrameStyle -> Directive[Black, Bold, 20], GridLines -> Automatic,
      GridLinesStyle -> LightGray, Ticks -> Automatic, 
     TicksStyle -> Directive[Black, Bold, 20], ImageSize -> 800], 
    Spacer[10], linelegend}], 
  Placed[{Spacer@{0, 20}, 
     TogglerBar[Dynamic[n], 
      MapIndexed[#2[[1]] -> 
         ToString[
           Framed[Style[#2[[1]], Black, Bold, 15], 
            ImageSize -> {45, 45}, Alignment -> Center, 
            Background -> colors[[#2[[1]]]]], StandardForm] <> 
          ToString[
           Framed[Style[#, Black, Bold, 15], ImageSize -> {230, 45}, 
            Alignment -> Center, Background -> White], 
           StandardForm] &, list], 
      Appearance -> "Vertical" -> {Automatic, 3}]} // Column, {Left, 
    Below}]]]*
$\endgroup$
10
  • 1
    $\begingroup$ Do any of the 100+ other indexed color schemes work for you? E.g., wrap a Manipulate around your code with a control to pick the color index a value other than 97. $\endgroup$
    – tad
    Aug 18 at 23:49
  • 4
    $\begingroup$ If you really must have all of those curves on a single figure, you might consider having at least two different thicknesses and/or line types (solid and dotted). $\endgroup$
    – JimB
    Aug 19 at 0:41
  • 1
    $\begingroup$ If intended to present to others, remember some will have different color perception than you. So JimB's suggestion for different line types will be more robust. $\endgroup$
    – tad
    Aug 19 at 0:57
  • 1
    $\begingroup$ You could use something like colors=Table[Hue[i, 0.5, 1.0], {i, 1/18, 1, 1/18}]. Which provide will evenly spaced hues. Playing around with the second argument for saturation, 0.5 seems to give the most easily distinguishable colors. But you still end up with some pink/purples that look close to me. You could also choose only 9 hues and add two steps in value, or saturation to make it a little easier to tell the difference. I also agree that color isn't the way to go here though. $\endgroup$
    – N.J.Evans
    Aug 19 at 12:30
  • 1
    $\begingroup$ Number of curves: thebrain.mcgill.ca/flash/capsules/experience_jaune03.html would suggest 7 items +/-2 is a limit for items that can be retained in short term memory. Number of colors that humans can distinguish: en.wikipedia.org/wiki/Color_vision : 10million according to this site. Board rooms are different. There you use the theme "Marketing" with one or two thick lines. If you say what you are trying to visualize, then I am sure someone will suggest an alternate visualization. $\endgroup$
    – Syed
    Aug 23 at 11:20
3
$\begingroup$

6 colors evenly spaced in Hue:
n=18;
a = Table[Hue[h, 1, 1], {h, 0, 1 - 3/n, 3/n}]
enter image description here

6 colors, offset in hue from above, with .75 brightness:
b = Table[Hue[h, 1, .75], {h, 1/n, 1 - 2/n, 3/n}]
enter image description here

6 colors, offset in hue from above, with 0.3 saturation:
c = Table[Hue[h, .3, 1], {h, 2/n, 1 - 1/n, 3/n}]
enter image description here

Put them all together:
mycolors2 = SortBy[Join[a, b, c], Hue]
enter image description here

Plot:
enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.