I am trying to plot a colz plot with a logarithmic z-axis. This should be easy, people keep telling me to use c->SetLogz(), yet this does not work.
What happens is that the scale along the z-axis becomes logarithmic like it should, yet the colours in the plot stay as they were… Not how it should be.
What I have is:
{
TCanvas *c8 = new TCanvas("c8","",w,h);
// gPad->SetLogz(1);
gPad->SetGrid();
myHistTotalCS("CS",7,10);
}
TH2F* myHistTotalCS(TString name , int Energy, int tanbeta)
{
if (gSystem->AccessPathName("prosp.root")) {
gROOT->ProcessLine(".x RootFileMaker.C");
}
TFile *f = new TFile("prosp.root");
TNtuple *ntuple = (TNtuple*)f->Get("ntuple");
if( gDirectory->Get(name) ) delete gDirectory->Get(name);
gStyle->SetPalette(1);
ntuple->Draw("m12:m0:TotalCS>>h5",cutname,"colz");
TH2F *h5 = (TH2F*)gDirectory->Get("h5");
return h5;
}
Thank you, but I tried this, using SetLogz(1), but somehow it did not work like in your example. I guess it might have something to do with how I fill the histogram?
Can you send a small example I can run ? this would really help to understand what is going wrong. Also, for completeness, I was running my example on a linux machine with the last ROOT version.
The colz option is for 2D histograms. Here you do a 3D variables plot. The histogram
h5 is empty. What you see in you plot are big square markers not the
histograms bins.
To produce a correct 2D histogram you should use TotalCS as weight (not as
3rd variable). Something like:
Apparently I cheered too soon… I thought it would work, yet now I am making these plots again, I see something is wrong.
Maybe I should have been more specific in what I wanted to plot…
What I am trying to get is a grid in this m0, m12 space, where on every point/bin it gives the value of the cross-section (“TotalCS”).
If I do
I get just the histogram, saying how many data points I have at each point in my (m0, m12) space. Which is 1 for all points…
when you do a x:y:z plot as you did before, each variable is mapped on one axis. The colz value is not valid. With the solution I gave you it does exactly what you says ie: fill a 2D histogram for with the colz option is valid.
In a TTree drawing, only when you plot 4 variables the 4th one is mapped on color: x:y:z:t…
may be try x:y:z:z