-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Check duplicate issues.
- Checked for duplicates
Description
With ROOT versions 6.36 and 6.38 (according to ChatGPT most probably with all versions starting at 6.30), the top row of pads has too large titles and first histogram Y axis labels. With e.g. ROOT 6.28.06 all pads look the same. This defies the purpose of using precision 3 fonts.
It is possible to workaround by canvas.Divide(3, 3, 0, 0) instead of using default margins in the Divide().
Furthermore, if TPad* pad1 = new TPad("c1", "c1", 0, 0, 1, 0.3); is changed to TPad* pad1 = new TPad("c1", "c1", 0, 0.01, 1, 0.3);, then fonts in this pad change and there is a difference between ROOT 6.36.06 and 6.38.00: too large font appears either in the top or bottom row of pads (here I mean pad pads, not pad0, pad1 pads).
Reproducer
Save the following as reproduce.C and run with root -b -n -l -q reproduce.C, then look at the produced pdf file reproduce.pdf
#include <TCanvas.h>
#include <TH1.h>
#include <TPaveText.h>
#include <TStyle.h>
TCanvas canvas;
template<class T>
void
SetFont(T* o, const int s = 8)
{
o->SetTextFont(43);
o->SetTextSize(s);
}
void
SetFonts(TAxis* a)
{
a->SetTitleFont(43);
a->SetTitleSize(9);
a->SetLabelFont(43);
a->SetLabelSize(8);
}
void
SetFonts(TH1* h)
{
SetFonts(h->GetXaxis());
SetFonts(h->GetYaxis());
}
void
DrawDist(TVirtualPad* pad, TH1* hData, TH1* hDelta)
{
pad->cd();
TPad* pad0 = new TPad("c0", "c0", 0, 0.3, 1, 1);
pad0->Draw();
pad0->cd();
pad0->SetBottomMargin(0);
pad0->SetTopMargin(0.10);
pad0->SetLogy();
hData->SetTitle("RST-, #LTp#GT = 4.34 GeV, log_{#lower[-0.2]{10}}(p/GeV) = 0.64, #LTp_{#lower[-0.3]{T}}#GT = 0.1 GeV");
auto SetAtts = [](TH1* h) {
h->SetMarkerColor(1);
h->SetLineColor(1);
h->SetMarkerSize(0.4);
h->SetLineWidth(1);
h->SetMarkerStyle(20);
};
SetAtts(hData);
SetFonts(hData);
hData->Draw("p");
pad0->Update();
TPaveText* titlePave = dynamic_cast<TPaveText*>(gPad->GetPrimitive("title"));
SetFont(titlePave);
pad->cd();
TPad* pad1 = new TPad("c1", "c1", 0, 0, 1, 0.3);
pad1->Draw();
pad1->cd();
pad1->SetBottomMargin(0.3);
pad1->SetTopMargin(0);
hDelta->GetYaxis()->SetRangeUser(-5.5, 5.5);
hDelta->GetYaxis()->SetNdivisions(505);
SetAtts(hDelta);
SetFonts(hDelta);
hDelta->Draw("p");
}
void
reproduce()
{
gStyle->SetOptStat(0);
TH1D h("", "", 100, -5, 5);
h.FillRandom("gaus");
TH1D h2("", "", 100, -5, 5);
h2.FillRandom("gaus");
canvas.Divide(3, 3);
for (int i = 0; i < 9; ++i)
DrawDist(canvas.GetPad(i + 1), &h, &h2);
canvas.SaveAs("reproduce.pdf");
}
ROOT version
ROOT v6.36.06
Built for linuxx8664gcc on Dec 09 2025, 21:46:09
From tags/v6-36-06@v6-36-06
With c++ (Debian 12.2.0-14+deb12u1) 12.2.0
Binary directory: /home/antek/Install/root/v6-36-06/install/bin
Installation method
build from source
Operating system
Linux Debian 12
Additional context
No response