Root Contour Colors

As you have probably found, by default ROOT applies a palette of colors to histograms that is completely inappropriate for this purpose:

Default root color example

You've probably also found that you can fix this by calling gStyle->SetPalette(1, 0), which gives you a rainbow palette instead. And if you also open up the histogram editor, you can set change the number of contours from the default 20 to 99:

Root color example with SetPalette(1, 0)

But this is still troublesome because any non-zero bin gets colored a very eye-catching purple, even if it is extremely close to zero and not worthy of notice. You can fix this by defining a custom palette. Here's mine at the moment (I stole aspects of it from examples around the web; it can probably be improved):

int NRGBs = 7, NCont = 999;
gStyle->SetNumberContours(NCont);
Double_t stops[NRGBs] = { 0.00, 0.10, 0.25, 0.45, 0.60, 0.75, 1.00 };
Double_t red[NRGBs]   = { 1.00, 0.00, 0.00, 0.00, 0.97, 0.97, 0.10 };
Double_t green[NRGBs] = { 1.00, 0.97, 0.30, 0.40, 0.97, 0.00, 0.00 };
Double_t blue[NRGBs]  = { 1.00, 0.97, 0.97, 0.00, 0.00, 0.00, 0.00 };
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);

And then you can set the number of contours as high as 999 with TH1::SetContour(), even though the graphical editor only lets you go to 99. (999 still seems arbitrary. Maybe someone should persuade the ROOT folks to go up to 1024 or 65536 or something more reasonable like that. Still, 999 is pretty darn good compared to 20 or 99.) Neato root color example

This palette fades to white on the low end so that people aren't distracted by very low values. (Obviously the speed at which the fade-to-white occurs needs to be tuned to how much very low values matter. You could easily use this technique to dishonestly obscure important low values.) While it's at it, it transitions from red to nearly black at the high end for more contrast.