1

I need to use the default scheme of Histogram in version 10 but cannot get this information. I know the default scheme used in Plot-like functions is ColorData[97], but it seems Histogram uses a different one. I tried Options which didn't help too much.

Can someone offer a hint?

sunt05
  • 4,367
  • 23
  • 34

1 Answers1

4

Thanks to the method here, with a minor modification for charts, we can get the answer as follows:

ClearAll[chartColors];
chartColors::usage="plotColors[plotType,plotTheme] gives a list of the colors used in a plot when several curves are drawn. Here plotType is, for example, Plot or ListLogPlot while plotTheme may be \"Scientific\", \"Classic\" etc.";

chartColors[chartType_,plotTheme_]:=("ChartDefaultStyle"/.(Method/.Charting`ResolvePlotTheme[plotTheme,chartType]))/.Directive[x_,__]:>x

The output is:

enter image description here

I then tried to look for the name/code of this scheme (something like ColorData[97]) but didn't get anything.


update: As @JasonB pointed out, the only difference between ColorData[97] and the default colour scheme of Histogram is the yellow colours and their sequence:

cl1=chartColors[Histogram,$PlotTheme];
cl2=ColorData[97,"ColorList"];
Complement[#,Intersection[cl1,cl2]]&/@{cl1,cl2}

The output is:

enter image description here

I cannot understand why WR would break the consistency in default colour schemes of plots/charts functions, in particular the change in colour sequence.

sunt05
  • 4,367
  • 23
  • 34
  • Look at the output of Thread[{chartColors[Histogram, "Default"] , ColorData[97] /@ Join[{2, 1}, Range[3, 15]]}], it looks like they just switch the first two colors, but it isn't quite true. That yellow color for the histogram is slightly different than the default second plotting color. – Jason B. Aug 12 '16 at 14:19
  • Yes, @JasonB, the change in colour is minimal. And I don't understand why WR would change the sequence. – sunt05 Aug 12 '16 at 16:10
  • Merely a guess, but perhaps this scheme was hard-coded before ColorData[97] was defined? Or perhaps someone in charge of Histogram thought that 97 needed adjustment and slipped this in? – Mr.Wizard Aug 13 '16 at 21:34
  • Anyway, this consistency devalues the beauty of Mathematica to me. – sunt05 Aug 13 '16 at 21:39
  • 1
    I am afraid I cannot help you see Mathematica as more beautiful, but you can modify the Histogram colors if you like, to use ColorData[97] instead. Would you like help with that? – Mr.Wizard Aug 14 '16 at 16:05
  • 1
    Just a note, the second example in the documentation under Histogram (multiple data sets) does not match the output in v12.1, as these colors are NOT reversed. – Chris K Oct 27 '20 at 21:31