# Define color palette based on the luminosity function

Hello!

Disclaimer: If you have experience in this area and think this would be over engineering a simple problem (that of good representation of magnitudes in the Z-direction of 2D histograms using colors) do share! I am a technical student at CERN who just started learning root this week.

Regarding root 5.

Is there anybody well-versed in root who could guide me through constructing and implementing a Color Palette based off the luminosity function*? Or have knowledge of previous implementations? If it has not been done I do believe there could be good interest for implementing it in future upgrades.

I’d like to implement the palette on images such as the one below.

I have only really managed the settings using the graphical interface.

*The luminosity function is a function, which unlike the rainbow color palette in root 5 which uses linear interpolation between wavelengths, has an adjusted interpolation to fit the human perception of color brightness to a specific wavelength: en.wikipedia.org/wiki/Luminosity_function

TIA
rjseen

So, I have been working a bit on the color scheme now, trying out a bunch of different combinations. I have not implemented the actual luminosity function, but rather guessed at what colours would be suitable. I am quite satisfied with the result, so if anyone want to borrow this color scheme I’ll post the code below the image. However, I still would like to implement the luminosity function, so do tell if you have any idea how! (or equally learn about an optimal color scheme for data representation)

[code]
int drawTest(){
Double_t w=900;
Double_t h=600;
TCanvas * c1=new TCanvas(“c”,“Momentum and missing mass squared”,w,h);
c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
gROOT->ProcessLine(“test->cd()”);
Int_t MyPalette[200];
Double_t r[] = {0., 0.0, 0.0, 0.0, 1.0, 1.0, 0.1};
Double_t g[] = {0., 0.0, 1.0, 0.3, 1.0, 0.0, 0.0};
Double_t b[] = {0.1, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0};
Double_t stop[] = {0., .1666, .33, .50, .66, .8333, 1.0};
Int_t FI=TColor::CreateGradientColorTable(7, stop, r, g, b, 200);

    for (int i=0;i<200;i++) MyPalette[i] = FI+i;

gStyle->SetPalette(200,MyPalette);

pippo->GetXaxis()->SetTitle("P");   //P_{\pi^{+/-}}");
pippo->GetYaxis()->SetTitle("Pmiss");//(P_{\pi^{+/-}}-P_{K^+})^2");
pippo->SetOption("cont4z1");

pippo->SetContour(99);

// Draw graph
pippo->Draw();
gStyle->SetOptStat("ne");
TPaveStats *s = (TPaveStats*)pippo->GetListOfFunctions()->FindObject("stats");
//new x start
s->SetX1NDC(0.6);
//new x end position
s->SetX2NDC(0.9);

//new y start
s->SetY1NDC(0.85);
//new y end position
s->SetY2NDC(0.9);

//set name
pippo->SetName("Momentum and missing mass squared");
c1->Modified();


} [/code]

Thanks. I will look at you code. Node that the pictures you posted here do not show.

For info with ROOT 6 I get:

Processing drawtest.C...
In file included from input_line_10:1:
c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
^
c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
^
c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
^
'pippo'
pippo->GetXaxis()->SetTitle("P");   //P_{\pi^{+/-}}");
^
'pippo'
pippo->GetYaxis()->SetTitle("Pmiss");//(P_{\pi^{+/-}}-P_{K^+})^2");
^
'pippo'
pippo->SetOption("cont4z1");
^
'pippo'
pippo->SetContour(99);
^