1
$\begingroup$

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?

$\endgroup$
5
  • 1
    $\begingroup$ Thanks! This helped me out: mathematica.stackexchange.com/a/66982/260, but in which the extraction key should be changed to ChartDefaultStyle. $\endgroup$
    – sunt05
    Aug 12, 2016 at 11:07
  • $\begingroup$ @sunt05 - you should post the answer here so it doesn't stay open as an unanswered question. $\endgroup$
    – Jason B.
    Aug 12, 2016 at 13:51
  • $\begingroup$ @JasonB, done. But I cannot find the code/name of this colour scheme, which seems to be a unique one and not an embedded entry in the ColorData collection. $\endgroup$
    – sunt05
    Aug 12, 2016 at 14:07
  • 2
    $\begingroup$ @Michael I favor closing this as a duplicate of (54486). Also related: (54545), (54629), (66923), (103829) $\endgroup$
    – Mr.Wizard
    Aug 13, 2016 at 21:31
  • $\begingroup$ @Mr.Wizard Yes, Charting`ResolvePlotTheme[ChartStyle, Histogram] adapted slightly from your PieChart example leads to a solution here. $\endgroup$
    – Michael E2
    Aug 14, 2016 at 11:44

1 Answer 1

4
$\begingroup$

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.

$\endgroup$
6
  • $\begingroup$ 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. $\endgroup$
    – Jason B.
    Aug 12, 2016 at 14:19
  • $\begingroup$ Yes, @JasonB, the change in colour is minimal. And I don't understand why WR would change the sequence. $\endgroup$
    – sunt05
    Aug 12, 2016 at 16:10
  • $\begingroup$ 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? $\endgroup$
    – Mr.Wizard
    Aug 13, 2016 at 21:34
  • 1
    $\begingroup$ 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? $\endgroup$
    – Mr.Wizard
    Aug 14, 2016 at 16:05
  • 1
    $\begingroup$ 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. $\endgroup$
    – Chris K
    Oct 27, 2020 at 21:31

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