Custom palette only for a specified range of values?

Greetings! I have this 3D data that I can now plot using CONT4Z option and I’m currently using palette 53 (black through red, yellow to white. The problem is that I have only z-points in the range 100 to 130, yet when I plot them they all appear almost white and the legend on the right shows that the colours go form 0 (black) to 130 (white), so the region I’m interested in is only a tiny fraction of the spectrum and is in almost the same colour. How can I fix that?

P.S. I did check the data file, there are NO points below z = 100.

You can make your own palette folowing the instructions given here:
root.cern.ch/drupal/content/how- … or-palette

Also you can try log scale along Z.

[quote=“couet”]You can make your own palette folowing the instructions given here:
root.cern.ch/drupal/content/how- … or-palette

Also you can try log scale along Z.[/quote]
Hi and thank you for your reply! I do not really need a log scale, I just need to set the “zero” of the palette (black) to some specific value. I had looked at that example above and I had tried doing that using the Length array in the example and just giving it the start, mid and end values of my data, but the colour palette was still starting from 0. What am I doing wrong?

Double_t zmin = pl->GetZmin(); Double_t zmax = pl->GetZmax(); const UInt_t paletteN = 3; Double_t paletteRed[paletteN] = {1.00, 0.00, 0.00}; // will change these later to use the red-orange-yellow Double_t paletteGreen[paletteN] = {0.00, 1.00, 0.00}; // will change these later to use the red-orange-yellow Double_t paletteBlue[paletteN] = {0.00, 0.00, 1.00}; // will change these later to use the red-orange-yellow Double_t paletteRange[paletteN] = {zmin, zmin/2 + zmax/2, zmax}; Int_t nb = 50; TColor::CreateGradientColorTable(paletteN, paletteRange, paletteRed, paletteGreen, paletteBlue, nb);

You mean the axis on the color palette ?
This axis goes from the z-minimal value of the histogram up to the z-maximal.
It is independent of the palette you define.

[quote=“couet”][quote]
but the colour palette was still starting from 0
[/quote]

You mean the axis on the color palette ?
This axis goes from the z-minimal value of the histogram up to the z-maximal.
It is independent of the palette you define.[/quote]
No, I mean the colours don’t match what I’ve specified in the palette - my data runs from z = 110 to z = 140 and I tried to explicitly set that:

  Double_t paletteRange[paletteN] = {110, 125, 140};

which as far as I understood (correct me if I’m wrong) means that red is at z = 110, green is at z = 125 and blue is at z = 140. But what I get is that: selected.png
It runs from blue at z = 0 (which is where no points lie) to read at z = 140 and all of my points lie in 2 shades of red only, so I see no detail there.


You use it the wrong way. Let me explain the example:


{
   TCanvas *c  = new TCanvas("c","Contours",600,0,600,600);
   TF2 *f1 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",1,3,1,3);
   UInt_t Number = 3;
   Double_t Red[Number]    = { 1.00, 0.00, 0.00};
   Double_t Green[Number]  = { 0.00, 1.00, 0.00};
   Double_t Blue[Number]   = { 1.00, 0.00, 1.00};
   Double_t Length[Number] = { 0.00, 0.50, 1.00 };
   Int_t nb=50;
   TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);
   f2->SetContour(nb);
   f2->Draw("surf1z");
}

In that case 3 colors are defined as “anchor”"

One at %0 (Lenght[0] = 0) of the of the Z range and it is RGB = 1 0 1
One at 50% (Lenght[1] = 0.5) of the of the Z range and it is RGB = 0 1 0
One at 100% (Lenght[2] = 1) of the of the Z range and it is RGB = 0 0 1

So you can define more colors around the range you want. The position of the colors in given in %

[quote=“couet”]You use it the wrong way. Let me explain the example:


{
   TCanvas *c  = new TCanvas("c","Contours",600,0,600,600);
   TF2 *f1 = new TF2("f2","0.1+(1-(x-2)*(x-2))*(1-(y-2)*(y-2))",1,3,1,3);
   UInt_t Number = 3;
   Double_t Red[Number]    = { 1.00, 0.00, 0.00};
   Double_t Green[Number]  = { 0.00, 1.00, 0.00};
   Double_t Blue[Number]   = { 1.00, 0.00, 1.00};
   Double_t Length[Number] = { 0.00, 0.50, 1.00 };
   Int_t nb=50;
   TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);
   f2->SetContour(nb);
   f2->Draw("surf1z");
}

In that case 3 colors are defined as “anchor”"

One at %0 (Lenght[0] = 0) of the of the Z range and it is RGB = 1 0 1
One at 50% (Lenght[1] = 0.5) of the of the Z range and it is RGB = 0 1 0
One at 100% (Lenght[2] = 1) of the of the Z range and it is RGB = 0 0 1

So you can define more colors around the range you want. The position of the colors in given in %[/quote]
Oohh, I see… Thanks, I will try to play around with that and see if I can get what I need!

 I can now plot using CONT4Z

May be for a try use COLZ instead

[quote=“couet”] I can now plot using CONT4Z

May be for a try use COLZ instead[/quote]
I did, thanks! And by defining more points around the values I’m interested in did what I wanted :slight_smile:

I am curious to see the picture you get now ?

The shape of the contours is the same, but the contrast is higher, so when I use that with my full data set it will make a difference (I hope)


Yes nice ! may be increase the number of levels to get a smoother coloring in the interesting zone.

Oh, yes, I will :slight_smile: Thanks again!

Again curious to see :slight_smile:

[quote=“couet”][quote]
Oh, yes, I will :slight_smile: Thanks again!
[/quote]

Again curious to see :slight_smile:[/quote]
I have 10 other stuff to deal with, but I will post it when I have some more spare time :slight_smile: