Setting color pallette of a surf1 plot of TGraph2D

Greetings all,

I have a series of TGraph2Ds which I plot using option “SURF1”.

The x, y and z axes are all plotted from 0 to 1.

I would like to make white the display color for those points on the surface plots where z==0 or z less than a small arbitrary value (e.g. z<0.1).

I am currently using a default color pallette for the SURF1 plots but the plots look very different when run on a linux system compared to a Windows 7 system (the color plotted for z==0 on linux is grey while for Windows it is dark blue).

I would be happy with grey-scale for the SURF1 plots, with the caveat that I would prefer the lightest possible color for z==0 (preferably white).

Any guidance you can give on this will be greatly appreciated.

I am using the standard ROOT 5.24 Windows executables on Windows 7 (I can’t use 5.26 because of the TGraph::Eval() issue). I am using ROOT 5.27/01 built from the trunk on linux.

Regards

The two following page explain how to create your own palette:

root.cern.ch/drupal/content/how- … or-palette
root.cern.ch/root/html/TColor.html#C05

Thank you for your response.

Generating a custom color pallette works fine, but my problem is that each of my attempts results in a pallette in which z==0 on a 0 to 1 scale is represented by a dark colour rather than white (or very light grey).

For some cases I can work around this by plotting the negative image of my data but this doesn’t cover all of the cases.

Could you please indicate for me how to force the colour assigned to teh lowest numerical values in my dataset to be a light colour and the highest values a dark colour. As noted above, my custom generated pallettes’ all seem to make the lowest values dark instead of light.

Regards

Can you post a small running macro shoving what your are doing ? I will then modify it in order to do what you are asking here.
Thanks in advance.

Thanks for your help.

The portion of my code that creates the color pallette is as follows

// const UInt_t Number = 2; Double_t Red[Number] = { 0.00, 1.00}; Double_t Green[Number] = { 0.00, 1.00}; Double_t Blue[Number] = { 0.00, 1.00}; Double_t Stops[Number] = { 0.00, 1.00}; // Int_t nb=100; TColor::CreateGradientColorTable(Number,Stops,Red,Green,Blue,nb); //

I have not sent this as a running script - but I can if that is necessary to solve the issue.

Regards

Here is a small example which, I think, does what you are looking for:

{
   TF2 *f1 = new TF2("f1","((y**2)/(40+9*sin(x))**(2) + 39.2*cos(x))",0,6.3,-150,150);
   f1->SetContour(50);
   Double_t max = f1->GetHistogram()->GetMaximum();
   Double_t min = f1->GetHistogram()->GetMinimum();
   Double_t val = 0;
   Double_t p   = (val-min)/(max-min);
   Double_t pe  = p+0.001;
   //
   const UInt_t Number = 4;
   Double_t Red[Number]   = { 1.00, 1.00, 0.00, 0.00};
   Double_t Green[Number] = { 1.00, 1.00, 0.00, 0.00};
   Double_t Blue[Number]  = { 1.00, 1.00, 1.00, 0.00};
   Double_t Stops[Number] = { 0.00,    p,   pe, 1.00};
   //
   Int_t nb=100;
   TColor::CreateGradientColorTable(Number,Stops,Red,Green,Blue,nb);
   f1->Draw("surf1");
}

Sorry for the delay in coming up with a running script - the working script calls a lot of files that are irrelevant to the problem at hand.

The TColor::CreateGradientColorTable is at line 63

Currently I have white at graph values of z==1 and black for z==0, I would like to reverse this but can’t figure out how.

Regards
TestScript.C (2.49 KB)

Does the script I send you answer your question ?
I looked at your script. Modify it the same in the same way of the one I sent you and it should be ok.

Thank you for your example script.

When I run your script it produces the result I am after - when I incorporate your code into my script something is going wrong.

I will try to sort out where my mistake is and come back with an additional question if necessary.

Thank you for your help.

Regards

I am trying to modify your script now … I’ll let you know.

Thank you - I have finally figured out where my misunderstanding of your example happened.

The script now produces exactly the effect I was aiming for.

Thank you for your help.