Publication Quality Graphics

Hi,

I know that this comes up a lot (I did google it before posting), but I was wondering if there is a directory/example/?? showing how to simply (as simply as possible) create publication quality graphics (for a paper, not a presentation) using ROOT (using ROOT 6) I found examples (e. g. from Babar), but they do not seem to work for me. The big problem is making the axis titles, labels, etc. the right size in the right place. When I use commands like

Myhisto->GetXaxis()->SetTitleSize( 0.06);

then the title overlaps with the tic labels or the plot below. ROOT is an amazingly sophisticated package; it is very disappointing that making plots suitable for inclusion in papers is so hard.

I do not need anything fancy; just nice-looking plot with 2-4 panels, each a 1-d histogram, on a fully white background, with appropriate sized axis labels and titles, and a reasonable number (i. e. not many) tic marks on the x and y axis. It should also work if the y axis is logarithmic.

I am sure that many many people would appreciate it if someone could produce (or provide an easily found pointer to) a simple, self-contained, up-to-date example that does this.

Thanks, and happy holidays.

Spencer Klein

1 Like

Hi Spencer,

the place to look is this one: https://root.cern/doc/master/group__Tutorials.html , graphs and graphics tutorials in particular as a start.
Now, to address your comments in a nutshell:

  • To increase the separation between axes and their title: myAxis->SetTitleOffset(X)
  • To divide a canvas in panels and draw histos:
TCanvas c;
c.Divide(2,2); // divides in 2x2 panels
c.cd(1); // select the 1st one
histo1.Draw();// draws the hypotetical 1st histo
c.cd(2); // select the 2nd one
histo2.Draw();// draws the hypotetical 2nd histo
...

As for the simple, self contained rich plot, we seriously consider your suggestion and will prepare something both in C++ and Python.

Cheers,
D

2 Likes

Hi Spencer!

Adding to Danilo, the way most people get nice graphics out of the box is by applying a style that’s agreed on by their experiment. I will try to get such a style and post it here - give me a couple of days, this will only happen after the holiday period.

Cheers, Axel.

I’d suggest using TikZ / PGFPlots. ROOT can output to the TikZ format, but I find building the pgfplot manually a much more clean and readable way. This also allows you to easily change axis labels, legend titles, etc. without having to return to ROOT. At one point I had started writing a library that could convert ROOT histograms to the corresponding pgfplot, but never found time to finish it.

An example:

FYI, I have also written a pgfplots converter library:

coupled with go-hep.org/x/hep/hbook/rootcnv (that converts ROOT TH{1,2}x histograms to Go HBOOK ones) one can very easily get publication quality plots.

hth,
-s

1 Like

Hi,

If you have some issue with one of your macro you can post it here and I will have a look.

Cheers,
O.

Many thanks to everyone who send me comments & suggestions. Unfortunately, I did not get what I was hoping for.

The two suggestions to output root histograms in TikZ format, and use a different program, like PGFPlots would probably have worked, but completely negates the benefits of an integrated environment.

Axel’s suggestion, that I copy a widely used style from an experiment is a great one, but if I had a style to copy, I wouldn’t have been posting. It would be really really great if the ROOT developers provided a simple example.

The pointers to specific commands were not needed; I already knew the commands, but am unable to find a decent way to deal with the interactions. Two specific examples:

What is the relationship between pad size and axis/title label font. After defining a canvas with a single pad;

TCanvas *c1 = new TCanvas(“Fig 3”,“Rapidity plots”,400,300);

I define and draw a histogram:

TH1D *ALICE6080rap = new TH1D("ALICE6080rap","",50,-10.,10.);

ALICE6080centraltrackcutsee ->Draw(“fsrap>>ALICE6080rap”);

define the labels

ALICE6080rap->GetXaxis()->SetTitle(“Pair Rapidity”);
ALICE6080rap->GetYaxis()->SetTitle(“d#sigma/dy (mb)”);

I then try to adjust the axis title and label font sizes:

ALICE6080rap->GetXaxis()->SetLabelSize( 0.05);
ALICE6080rap->GetYaxis()->SetLabelSize( 0.05);
ALICE6080rap->GetXaxis()->SetTitleSize( 0.05);
ALICE6080rap->GetYaxis()->SetTitleSize( 0.05);

and then I draw it

ALICE6080rap->Draw();

This produces axis labels that are (just barely) acceptable; the bottom of the ‘y’ in the x axis label is just barely cut off. Anther plot, with the same format has a subscript ‘T’ which is also barely cut off, by a different amount when I look at the plot on-screen rather than embedding it in a .tex file.

If I could, I would have made the axis titles a bit larger. But then, depending on where I positioned them, the x axis components would be either cut off below, or overlapped with the axis labels. If I moved the x axis label up, it would overlap with the plot,etc. I could probably figure out how to move the plot upward a bit, but is way too much trial and error. Is this really how a plotting package is supposed to work?

Unfortunately, the problem got worse when I made a canvas with two panels, one atop the other.

TCanvas *c1 = new TCanvas(“Fig 2”,“ptsq plots”,400,600);

c1->Divide(1,2);
c1->cd(1);

STAR6080ptsq->GetXaxis()->SetTitle(“p_{T}^{2} (GeV/c)^{2}”);
STAR6080ptsq->GetXaxis()->SetTitleOffset(0.9);
STAR6080ptsq->GetXaxis()->SetLabelSize( 0.05);
STAR6080ptsq->GetYaxis()->SetLabelSize( 0.05);
STAR6080ptsq->GetXaxis()->SetTitleSize( 0.05);
STAR6080ptsq->GetYaxis()->SetTitleSize( 0.05);
STAR6080ptsq->GetYaxis()->SetTitle(“Number/bin”);
STAR6080ptsq->GetXaxis()->SetNdivisions(504);

Then, the same title sizes produced noticeably smaller labels, even though the pad was twice as large as before. The Title Offset above was also needed to minimize the overlap/bottom getting cut off.

If anyone wants to see the results, they are the plots in arXiv:arXiv:1801.04320. The issues with the font sizes for single vs. double panel plots are obvious there.

If anybody can point me to working examples like this, I would be grateful.

Thanks again.

Spencer

Thanks for your reply. Can you post a macro I can run an work on ? I think That would be the best way to help.

FYI:

@Axel I am also interested to get such a style. Did you get one?

Yes! Posting it here Publication-quality ROOT Graphics Style from ATLAS for now, until we find a more prominent home.

This is a donation from ATLAS - thanks a lot, ATLAS!

1 Like

A new Style “ATLAS” has been introduced in TStyle.
And an example showing how it looks like has been added as a tutorial.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.