rene
1
Hello,
is there a way to show (part of) the first bin of a histogram whose x-axis starts from 0, when logarithmic x-axis is set?
I tried
{
TCanvas *c = new TCanvas();
TH1F *x = new TH1F("x", "x", 100, 0, 100);
x->Fill(0.01, 100);
x->Fill(1, 1);
x->Fill(10, 10);
x->Draw();
c->SetLogx();
x->GetXaxis()->SetRangeUser(0.001, 100);
}
and it does not work.
couet
2
{
TCanvas *c = new TCanvas();
TH1F *x = new TH1F("x", "x", 100, 0, 100);
x->Fill(0.01, 100);
x->Fill(1, 1);
x->Fill(10, 10);
x->Draw();
x->GetXaxis()->SetLimits(0.001, 100);
c->SetLogx();
}
rene
3
it doesn’t really work with variable bins:
{
TCanvas *c = new TCanvas();
Double_t edges[8] = { 0, 1, 2, 3, 4, 5, 7, 10 };
TH1F *x = new TH1F("x", "x", 7, edges);
x->Fill(0.01, 100);
x->Fill(1, 1);
x->Fill(10, 10);
x->Draw();
x->GetXaxis()->SetLimits(0.001, 100);
c->SetLogx();
}
couet
4
What is it supposed to do in that case ?
rene
5
the same it does in the example you provided, i.e. keep on printing the first bin instead of skipping it
couet
6
I am not sure that can work on non equidistant bins. I’ll ask.
couet
7
The best is to do:
{
TCanvas *c = new TCanvas();
Double_t edges[8] = { 0.001, 1, 2, 3, 4, 5, 7, 10 };
TH1F *x = new TH1F("x", "x", 7, edges);
x->Fill(0.01, 100);
x->Fill(1, 1);
x->Fill(10, 10);
x->Draw();
c->SetLogx();
}
couet
8