# Publication Quality Graphics

**URL:** <https://root-forum.cern.ch/t/publication-quality-graphics/27402>\
**Category:** ROOT\
**Created:** [December 30, 2017, 9:48pm UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402 "2017-12-30T21:48:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![spencer](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/spencer/32/39846_2.png) [@spencer](https://root-forum.cern.ch/u/spencer)\
**Post date:** [December 30, 2017, 9:48pm UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/1 "2017-12-30T21:48:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [December 31, 2017, 8:25am UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/2 "2017-12-31T08:25:31Z")

</div>

Hi Spencer,

the place to look is this one: [https://root.cern/doc/master/group\_\_Tutorials.html](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:

```auto
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
...

```

- The white background is the ROOT default
- Appropriarte titles: this can be selected only by the scientist/engineer preparing the plot 😉 Latex symbols can help: [https://root.cern.ch/doc/master/classTLatex.html](https://root.cern.ch/doc/master/classTLatex.html)
- Ticks: ROOT selects a default number. Is it appropriate for you?
- Log axis: [https://root.cern/doc/master/zdemo\_8C.html](https://root.cern/doc/master/zdemo_8C.html)

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

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [January 2, 2018, 6:32am UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/3 "2018-01-02T06:32:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [January 2, 2018, 8:34pm UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/4 "2018-01-02T20:34:46Z")

</div>

I’d suggest using TikZ / [PGFPlots](http://pgfplots.sourceforge.net/). 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:

> [@Unwanted borders around fill areas when canvas is printed as a .tex](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623):
>
> Hi ROOTers, While making some PDFs of ROOT plots that I printed to .tex files (see [here](https://root-forum.cern.ch/t/tmathtext-and-transparency-on-the-same-pdf/24566/3)), I’m finding that filled areas, such as TGraph error bands with draw options \>= 2, have borders around them that don’t appear in other formats. When the area has a solid fill, the border is the same color as the fill so it doesn’t look terrible, but the line thickness changes the size of the filled region. When I fill the area with a pattern, the box is always black. The following Python script demonstrates…

---

<div class="post-metadata">

**Author:** ![sbinet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sbinet/32/13166_2.png) [@sbinet](https://root-forum.cern.ch/u/sbinet)\
**Post date:** [January 2, 2018, 9:09pm UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/5 "2018-01-02T21:09:02Z")

</div>

FYI, I have also written a pgfplots converter library:

- [https://github.com/go-hep/hep/tree/master/hplot#latex-plots](https://github.com/go-hep/hep/tree/master/hplot#latex-plots)
- [https://github.com/go-hep/hep/raw/master/hplot/testdata/latex\_plot\_golden.pdf](https://github.com/go-hep/hep/raw/master/hplot/testdata/latex_plot_golden.pdf)

coupled with [go-hep.org/x/hep/hbook/rootcnv](http://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

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 8, 2018, 9:45am UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/6 "2018-01-08T09:45:25Z")

</div>

Hi,

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

Cheers,  
O.

---

<div class="post-metadata">

**Author:** ![spencer](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/spencer/32/39846_2.png) [@spencer](https://root-forum.cern.ch/u/spencer)\
**Post date:** [January 17, 2018, 10:14pm UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/7 "2018-01-17T22:14:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 18, 2018, 7:35am UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/8 "2018-01-18T07:35:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [January 18, 2018, 2:33pm UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/9 "2018-01-18T14:33:28Z")

</div>

FYI:

> [@Getting the same histograms after cuts](https://root-forum.cern.ch/t/getting-the-same-histograms-after-cuts/24719/2):
>
> Remark on the way to post code snippets: When you post pieces of code on the forum enclose it with ``` . That makes your post much more readable (I systematically edit your posts that way) . So do: ``` // this is a C++ piece of code. ``` And it will display as: // this is a C++ piece of code.

---

<div class="post-metadata">

**Author:** ![pamputt](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pamputt/32/12526_2.png) [@pamputt](https://root-forum.cern.ch/u/pamputt)\
**Post date:** [January 18, 2018, 2:58pm UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/10 "2018-01-18T14:58:20Z")

</div>

> [@Axel](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [January 30, 2018, 10:32am UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/11 "2018-01-30T10:32:49Z")

</div>

Yes! Posting it here [Publication-quality ROOT Graphics Style from ATLAS](https://root-forum.cern.ch/t/publication-quality-root-graphics-style-from-atlas/27751) for now, until we find a more prominent home.

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

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 8, 2018, 8:43am UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/12 "2018-02-08T08:43:35Z")

</div>

> [@Axel](#):
>
> until we find a more prominent home.

A new Style “ATLAS” has been introduced in TStyle.  
And an example showing how it looks like has been added as a [tutorial](https://root.cern/doc/master/AtlasExample_8C.html).

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [February 22, 2018, 8:43am UTC](https://root-forum.cern.ch/t/publication-quality-graphics/27402/13 "2018-02-22T08:43:41Z")

</div>

Closed on February 22, 2018, 8:43am UTC

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