How to rescale Draw("COLZ")

I got a x y z ASCII format and usd Tgraph2D to draw

how does one rescale Draw(“COLZ”) along z-axis. it show 5.2,5.3,…5.9 to 5.2,5.4,5.6,…

Can you send a small running macro showing what you are talking about ?

void n2d(){
  gROOT->SetStyle("Plain");
  gStyle->SetPalette(1);

  TGraph2D *gr2 = new TGraph2D("s18.dat");
  
  TCanvas *c1 = new TCanvas("s18","TGraph2d",700,700);
  gr2->SetTitle("Sample 18 [Ti02:Cement = 1:600], Log Plot");
  gr2->GetYaxis()->SetTitle("#Theta (Top to Bottom)");
  gr2->GetYaxis()->CenterTitle();
  gr2->GetYaxis()->SetTitleOffset(1.2);
  gr2->GetYaxis()->SetRangeUser(0,180.);
  gr2->GetXaxis()->SetTitle("#Phi");
  gr2->GetXaxis()->CenterTitle();
  gr2->GetXaxis()->SetTitleOffset(1.2);
  gr2->GetXaxis()->SetRangeUser(0.,360.);
  gr2->GetZaxis()->SetTitle("Log[Counts]");
  gr2->GetZaxis()->CenterTitle();
  gr2->GetZaxis()->SetTitleOffset(1.5);
  


  //gr2->Draw("tri2"); 
  //gr2->Draw("surf1");
  //gr2->Draw("CONT4");
  gr2->Draw("COLZ");
}

The data file is missing so the macro does not work. Any way you can get the histogram from the graph with:

gr2->GetHistogram()

and then manipulate the histogram.

Bu I do need to plot in a contour plot of x and y and the counts shown in Z.

I would like to manipulate the rebin the z-zxis

i’m attaching the datafile

I am not sure to understand what you mean by “manipulate” the Z axis.
Once you have the histogram (thanks to GetHistogram) you can then set the maximum and minimum to change the limits (SetMaximum() SetMinimum())

I was thinking of rescaling the countor plot.

the ps file attachd should this. I would like the countor plot the color scale to go from 0.2 increment instead of 0.1

there is no ps file attached …

here is the ps file
s18.ps (50.3 KB)

here is the datafile

datafile look something like this

0 30 4.212480588
0 50 4.095831625
0 70 3.91944421
0 90 3.823734988
0 110 3.745152895
0 130 3.695218919
0 150 3.644340099
0 170 3.643057684
20 30 4.247015291
20 50 4.114744388
20 70 3.931762888
20 90 3.826593054
20 110 3.72916479
20 130 3.644143051
20 150 3.560026249
20 170 3.537693194
40 30 4.19049978
40 50 4.045987606
40 70 3.912062556
40 90 3.817102404
40 110 3.713910354
40 130 3.641969598
s18.txt (2.68 KB)

void n2d(){ 
  gROOT->SetStyle("Plain"); 
  gStyle->SetPalette(1); 
  TGraph2D *gr2 = new TGraph2D("s18.dat"); 
  TCanvas *c1 = new TCanvas("s18","TGraph2d",700,700); 
  gr2->SetTitle("Sample 18 [Ti02:Cement = 1:600], Log Plot"); 
  gr2->GetYaxis()->SetTitle("#Theta (Top to Bottom)"); 
  gr2->GetYaxis()->CenterTitle(); 
  gr2->GetYaxis()->SetTitleOffset(1.2); 
  gr2->GetYaxis()->SetRangeUser(0,180.); 
  gr2->GetXaxis()->SetTitle("#Phi"); 
  gr2->GetXaxis()->CenterTitle(); 
  gr2->GetXaxis()->SetTitleOffset(1.2); 
  gr2->GetXaxis()->SetRangeUser(0.,360.); 
  gr2->GetZaxis()->SetTitle("Log[Counts]"); 
  gr2->GetZaxis()->CenterTitle(); 
  gr2->GetZaxis()->SetTitleOffset(1.5); 
  TH2D *h2 = gr2->GetHistogram();
  h2->Draw("CONT4Z"); 
  h2->SetContour(10);
} 

thanks

How does one change the plot range from in Y axis from 0,20,… to 100 to decending order of 100,80,…0

I put an example there:
couet.web.cern.ch/couet/root/ht16.html

[quote=“couet”]I put an example there:
couet.web.cern.ch/couet/root/ht16.html[/quote]

thanks for this examples but the the axis changes but not the data
I would like to plot the data in terms of theta from 180 to 0 instead of 0 to 180

here is the code I used.

void t(){
gROOT->SetStyle(“Plain”);
gStyle->SetPalette(1);
TGraph2D *gr2 = new TGraph2D(“g-4.dat”);
TCanvas *c1 = new TCanvas(“G”,“TGraph2d”,700,700);
gr2->SetTitle(“G Linear Plot”);
gr2->GetYaxis()->SetTitle("#Theta");
gr2->GetYaxis()->CenterTitle();
gr2->GetYaxis()->SetTitleOffset(1.2);
gr2->GetYaxis()->SetRangeUser(0,180.);
gr2->GetXaxis()->SetTitle("#Phi");
gr2->GetXaxis()->CenterTitle();
gr2->GetXaxis()->SetTitleOffset(1.2);
gr2->GetXaxis()->SetRange(360,0.);
gr2->GetXaxis()->SetRangeUser(360.,0.);
gr2->GetZaxis()->SetTitle(“Log[Counts]”);
gr2->GetZaxis()->CenterTitle();
gr2->GetZaxis()->SetTitleOffset(1.5);
gr2->GetZaxis()->SetRangeUser(.6,1.2); // g-6,g-5,g-4

TH2D *h2 = gr2->GetHistogram();
h2->SetContour(6); // g-5,g-6
h2->Draw(“CONT4Z”);

}

g-4.dat data look like
20 22 0.511
20 36 0.668
20 53 0.947
20 71 1.168
20 90 1.223
20 109 1.185
20 127 1.088
20 144 1.020
20 158 0.972
60 61 0.949
60 64 0.997
60 71 1.053
60 80 1.067
60 90 1.070
60 100 1.038
60 109 1.004
60 116 0.972
60 119 0.947
120 64 0.901
120 71 0.924
120 80 0.958
120 90 0.969
120 100 0.958
120 109 0.937
120 116 0.929
120 119 0.933
160 36 0.662
160 53 0.851
160 71 1.011
160 90 1.076
160 109 1.043
160 127 0.981
160 144 0.940
160 158 0.942
200 36 0.754
200 53 0.915
200 71 1.030
200 90 1.066
200 109 1.036
200 127 0.983
200 144 0.952
200 158 0.935
240 64 1.003
240 71 1.013
240 80 1.013
240 90 1.012
240 100 1.004
240 109 0.987
240 116 0.970
240 119 0.964
300 61 0.996
300 64 1.054
300 71 1.063
300 80 1.112
300 90 1.116
300 100 1.086
300 109 1.053
300 116 1.006
300 119 0.976
340 22 0.709
340 36 0.857
340 53 1.036
340 71 1.191
340 90 1.242
340 109 1.196
340 127 1.117
340 144 1.033
340 158 0.971