marek
October 13, 2005, 8:13am
1
Hello,
would you have please any advice on how to modify the Palette to have
non-equidistant bins in z-var.? I found I can change the number of colors
by
Int_t colors[3] = {kRed, kYellow, kGreen};
gStyle->SetPalette(3,colors);
but for colz option in TGraph2D, I’d need a special z-var.-to-color assignment, e.g.:
z = 0...0.2 => color=red
z = 0.2...1.0 => color=yellow
z > 1.0 => color=green
Thank you very much for any tip.
Marek
couet
October 13, 2005, 8:44am
2
{
TCanvas *c = new TCanvas("c","Contours",0,0,800,700);
TFile f("hsimple.root");
Double_t cl[4] = {0.1, 1, 10, 100};
hpxpy->SetContour(4,cl);
hpxpy->SetMinimum(0.01);
Int_t colors[4] = {kRed, kYellow, kGreen, kBlue};
gStyle->SetPalette(4,colors);
hpxpy->Draw("col z");
}
Note: hsimple.root is created in by $ROOTSYS/tutorials/hsimple.C
marek
October 14, 2005, 2:17pm
3
Thank you very much, it works. May I have sort of a question
connected to this which was already asked in this forum
but whose solution didn’t help me?
I’d like to have two palettes in one canvas. The following didn’t work (it means the 1st pad was redrawn following the
2nd palette):
gStyle->SetPalette(1);
c->cd(1);
TGraph2D *w1 = new TGraph2D(1701,mA0,tanb,A);
w1->DrawClone(“contcolz”);
c->cd(2);
TGraph2D w2 = new TGraph2D(1701,mA0,tanb,A);
TH2D h2 = w2->GetHistogram(“h2”);
double contours[3]={0,0.2,1};
h2->SetContour(3,contours);
Int_t colors[3] = {kBlue, kGreen, kYellow};
gStyle->SetPalette(3,colors);
h2->SetDrawOption(“col”);
h2->Draw(“contcolz”);
I’ll be grateful for any tip. Marek
couet
October 14, 2005, 2:27pm
4