Hi,
I want to create and Draw() a histogram w/ variable-sized bins, especially in a scale which is evenly spaced in logarithmic space.
When I create and draw such a histogram (with the following script) on a canvas with SetLogx(kFalse) there’s no problem (histograms on the left row in the attached picture), but the histogram looks strange when drawn on a canvas w/ SetLogx(kTrue) (those on the right row).
How can I fix this?
Thanks in advance.
Kazuyoshi
{
const Double_t eb[] = {1.e0, 1.e1, 1.e2, 1.e3, 1.e4, 1.e5};
TH1D *testH = new TH1D("testH","testH", 5,eb);
testH->SetStats(kFALSE);
for (Int_t bin=1; bin<=5;bin++) {
testH->SetBinContent(bin, 3.*pow(10,(bin-1)) );
testH->SetBinError( bin, 3.*pow(10,(bin-1))*0.5);
}
TCanvas *can = new TCanvas("can","can");
can->Divide(2,2);
can->cd(1); gPad->SetGrid(); gPad->SetLogy();
testH->Draw("");
can->cd(2); gPad->SetGrid(); gPad->SetLogy(); gPad->SetLogx();
testH->Draw("");
can->cd(3); gPad->SetGrid(); gPad->SetLogy();
testH->Draw("hist e");
can->cd(4); gPad->SetGrid(); gPad->SetLogy(); gPad->SetLogx();
testH->Draw("hist e");
can->Print("testH.png");
}
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.20/02
Platform: linuxx8664gcc(Fedora release 31 (Thirty One))
Compiler: g++ (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1)