Problem Superimposing Histograms

Hello all, I’m having a problem with axis labels when I superimpose histograms from two different .root files. I spent some time getting the axis labels perfect for the histograms in each .root file, but for some reason when I superimpose these histograms, the labels get cut in half, or disappear entirely.

I’ve uploaded some .pdfs to illustrate my problem, and also the macro that I wrote.

This seems like a problem that should be extremely easy to fix, but I’m at a loss to what went wrong. I’m sure that the problem is my macro that superimposes the histograms, any help as to what changes I can make to said macro to fix the problem would be much appreciated.
Sideband_Signal_Comparison.C (12.8 KB)
B_AMAXDOCA_sg_uppersb_comparison.pdf (15.6 KB)
B_AMAXDOCA_sg.pdf (14.5 KB)
B_AMAXDOCA_sb.pdf (14.4 KB)

Try to execute your macro without the initial line:
gROOT -> ProcessLine (".x lhcbstyle.C");

Hi, thanks for the quick response! I tried what you suggested, but the result was the same. No changes in the axis labels, unfortunately.

Try this: [code]{
TLegend *leg;
TFile f1(“Signal_Histograms.root”);
TFile f2(“Upper_Sideband_Histograms.root”);

TH1F *h45; f1.GetObject(“h_B_AMAXDOCA_sg”, h45);
if (!h45) return; // just a precaution
TH1F *h46; f2.GetObject(“h_B_AMAXDOCA_sb”, h46);
if (!h46) return; // just a precaution
h45->SetLineColor(kRed);
h45->SetFillColor(kRed);
h45->SetFillStyle(3003);
h46->SetLineColor(kBlue);

TCanvas *c23sg = new TCanvas(“c23sg”, “c23sg”);
h45->Draw(“l”);
c23sg->Update();
leg = new TLegend(0.67,0.67,0.90,0.90);
leg->SetHeader(“Legend”);
leg->AddEntry(h45, “Signal Distribution”, “f”);
leg->Draw();
c23sg->Update();
c23sg->Print(“h_B_AMAXDOCA_sg.pdf”);

TCanvas *c23sb = new TCanvas(“c23sb”, “c23sb”);
h46->Draw(“l”);
c23sb->Update();
leg = new TLegend(0.67,0.67,0.90,0.90);
leg->SetHeader(“Legend”);
leg->AddEntry(h46, “Upper Sideband Distribution”, “l”);
leg->Draw();
c23sb->Update();
c23sb->Print(“h_B_AMAXDOCA_sb.pdf”);

TCanvas *c23 = new TCanvas(“c23”, “c23”);
h45->Draw(“l”);
h46->Draw(“same”);
c23->Update();
leg = new TLegend(0.67,0.67,0.90,0.90);
leg->SetHeader(“Legend”);
leg->AddEntry(h45, “Signal Distribution”, “f”);
leg->AddEntry(h46, “Upper Sideband Distribution”, “l”);
leg->Draw();
c23->Update();
c23->Print(“B_AMAXDOCA_sg_uppersb_comparison.pdf”);
}[/code]

Hello again, I tried what you suggested and this time it printed out the sb, sg and comparison .pdfs, all of which had the problematic axis labels. I’ve uploaded the three generated .pdfs.
h_B_AMAXDOCA_sg.pdf (14.8 KB)
h_B_AMAXDOCA_sb.pdf (14 KB)
B_AMAXDOCA_sg_uppersb_comparison.pdf (15.6 KB)

So, check if you have any file:
ls -al ${HOME}/.rootrc ./.rootrc ${HOME}/rootlogon.C ./rootlogon.C ${HOME}/rootalias.C ./rootalias.C

I have a rootlogon.C in my root->test->histviewer directory, a rootalias.C in my root->tutorials directory, and a rootrc.in in my root->config directory… not sure if that’s what you mean, when I put “ls -al ${HOME}/.rootrc ./.rootrc” (and likewise for the other two) into my terminal, I get the message that there is no such file or directory…

So, if you do not have any of the files that I listed then you get the “bare” ROOT behaviour when drawing now.
I don’t know what your did when you “spent some time getting the axis labels perfect”, but it seems that this may be the origin of the problem (the small macro that I posted returns “consistent” results in all three canvases).

What I meant by the “perfect axis” thing is I spent some time playing with the SetTitleOffset parameter on my histograms until I got the axis labels exactly where I wanted them. Without it, the axis labels for my histograms ended up getting superimposed on the axis values.

Well, it is possible that, when you were playing with your histograms, you were using some global “style” settings which you do not use now.

I’ve maybe got an idea … try again my macro, but right in the beginning (i.e. right after the “{” line) add:
gROOT->ProcessLine(".x lhcbstyle.C");
gROOT->ForceStyle(kTRUE);