# Unwanted borders around fill areas when canvas is printed as a .tex

**URL:** <https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623>\
**Category:** ROOT\
**Created:** [May 3, 2017, 9:51am UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623 "2017-05-03T09:51:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nwoods](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@nwoods](https://root-forum.cern.ch/u/nwoods)\
**Post date:** [May 3, 2017, 9:51am UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/1 "2017-05-03T09:51:36Z")

</div>

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 the problem when run on an SLC6 system with ROOT 6.06 and the appropriate LaTeX packages installed.

```python
from ROOT import TGraphAsymmErrors, TCanvas
from os import system

c = TCanvas("c","c",1000,1000)
g = TGraphAsymmErrors(3)
for i in range(3):
    g.SetPoint(i,i+1.,i+1.)
    g.SetPointError(i,0.25,0.25,0.25,0.25)
g.SetFillColorAlpha(628,0.5)
g.SetFillStyle(3013)
g.SetLineColor(600)
g.Draw("a2")
c.Print("imageAsPDF.pdf")
c.Print("c.tex","tex")

latexFrame = '''
\\documentclass[tikz]{standalone}
\\usepackage{standalone}
\\usetikzlibrary{patterns}
\\usetikzlibrary{plotmarks}
\\usepackage{amsmath}
\\begin{document}
  \\input{c.tex}
\\end{document}
'''

with open("imageAsTeX.tex","w") as f:
    f.write(latexFrame)

system("pdflatex imageAsTeX.tex")                                                                                                                                                                            

```

I can make the border disappear by editing c.tex by hand or with a regex to replace `\draw` with `\path` when it defines the relevant objects.

Cheers,  
Nate

---

<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:** [May 3, 2017, 11:39am UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/2 "2017-05-03T11:39:13Z")

</div>

Hi Nate,

I do not see a such border on Mac. I have taken your example (converted into C++), ran it,  
made a `.tex` file to include it (same way as you did), generated the pdf file using `pdflatex`, and preview the resulting pdf file on screen using `preview`. I get the following output on screen:

 ![](https://root-forum.cern.ch/uploads/default/original/2X/d/da46712cd4f9f8da3bdfc703b06d0698ff15bdca.png)

I am using ROOT master on Mac.

Cheers,  
Olivier

---

<div class="post-metadata">

**Author:** ![nwoods](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@nwoods](https://root-forum.cern.ch/u/nwoods)\
**Post date:** [May 3, 2017, 12:04pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/3 "2017-05-03T12:04:32Z")

</div>

Hi Olivier,

Interesting! I made mine on SLC6 and the boxes appear in several PDF viewers on SLC6 and Ubuntu (the PDF viewer in Firefox on Ubuntu replaces the hatching with hundreds of tiny arrows for some reason, but this is a separate issue). Here’s what it looks like in Evince on Ubuntu

 ![](https://root-forum.cern.ch/uploads/default/original/2X/7/782a3e597b4ca2bedf5ac4cd6d94fdb44e3255e2.png)

Here’s the PDF (zipped to allow upload) if you want to see what it looks like for you in Preview.  
[imageAsTeX.zip](https://root-forum.cern.ch/uploads/default/original/2X/5/5de48703b4d4ee9d1654ef0d9df162dd5afbece7.zip) (7.1 KB)

Cheers,  
Nate

---

<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:** [May 3, 2017, 12:17pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/4 "2017-05-03T12:17:51Z")

</div>

Yes your file has the borders with `preview` also. Attached the files I used:  
[tex.tar](https://root-forum.cern.ch/uploads/default/original/2X/f/f8fbf640e39541f053ed84087ffa0a9081f234b2.tar) (14.5 KB)

---

<div class="post-metadata">

**Author:** ![nwoods](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@nwoods](https://root-forum.cern.ch/u/nwoods)\
**Post date:** [May 3, 2017, 1:01pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/5 "2017-05-03T13:01:50Z")

</div>

Ok, now I’m totally confused. When I compile your version unedited with `pdflatex` on Ubuntu, the boxes don’t show up at all. I did a diff of yours and mine, which found (among lots of small numerical differences)

> ## 151,153c151,153 \< \draw [pattern=crosshatch, draw opacity=0, pattern color=c, fill opacity=0.5] (3.33333,3.25651) rectangle (6,5.86172); \< \draw [pattern=crosshatch, draw opacity=0, pattern color=c, fill opacity=0.5] (8.66667,8.46693) rectangle (11.3333,11.0721); \< \draw [pattern=crosshatch, draw opacity=0, pattern color=c, fill opacity=0.5] (14,13.6774) rectangle (16.6667,16.2826);
> 
> \> \draw [pattern=crosshatch, pattern color=c, fill opacity=0.5] (3.33333,3.25301) rectangle (6,5.85542);  
> \> \draw [pattern=crosshatch, pattern color=c, fill opacity=0.5] (8.66667,8.45783) rectangle (11.3333,11.0602);  
> \> \draw [pattern=crosshatch, pattern color=c, fill opacity=0.5] (14,13.6627) rectangle (16.6667,16.2651);

(yours are the first three lines). When I set your `draw opacity` nonzero, the points show up – with the black boxes around them.

This is really bizarre. Our ROOT code looks the same to my eye, so I don’t understand why the `draw opacity` is different, and I also don’t understand why my version of `pdflatex` interprets that to mean the boxes should be invisible while yours draws them fully opaque anyway.

Here are the versions of my various tools:  
ROOT 6.06/01  
`pdflatex` version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian)  
`standalone` v1.2  
`pgf` v3.0.1a (rcs-revision 1.15)  
`tikz` v3.0.1a (rcs-revision 1.151)

---

<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:** [May 3, 2017, 1:12pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/6 "2017-05-03T13:12:35Z")

</div>

I am using:

ROOT 6.09/03  
pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012)

---

<div class="post-metadata">

**Author:** ![nwoods](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@nwoods](https://root-forum.cern.ch/u/nwoods)\
**Post date:** [May 3, 2017, 1:38pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/7 "2017-05-03T13:38:36Z")

</div>

I compiled yours again on the SLC6 machine, which is using `pdflatex` version 3.141592-1.40.3 (Web2C 7.5.6), which is older than yours. It behaved the same as on Ubuntu, so I guess that’s not the difference.

---

<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:** [May 3, 2017, 1:48pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/8 "2017-05-03T13:48:55Z")

</div>

I tried once again with the file sent you. I am doing:

```auto
$ root latexframe.C 
root [0] 
Processing latexframe.C...
Info in <TCanvas::Print>: pdf file imageAsPDF.pdf has been created
Info in <TCanvas::Print>: TeX file c.tex has been created
root [1] .q
$ ls -lrt
total 104
-rw-r--r--@ 1 couet staff 347 May 3 13:29 latexframe.C
-rw-r--r--@ 1 couet staff 178 May 3 13:34 textdumpc.tex
-rw-r--r-- 1 couet staff 14848 May 3 14:28 tex.tar
-rw-r--r-- 1 couet staff 13465 May 3 15:43 imageAsPDF.pdf
-rw-r--r-- 1 couet staff 8970 May 3 15:43 c.tex
$ pdflatex textdumpc.tex
This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012)
[...]
$ open textdumpc.pdf

```

 ![](https://root-forum.cern.ch/uploads/default/original/2X/9/971a6e2dd747ddaf3068f6f14481c6c76516f464.png)

---

<div class="post-metadata">

**Author:** ![nwoods](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@nwoods](https://root-forum.cern.ch/u/nwoods)\
**Post date:** [May 3, 2017, 2:07pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/9 "2017-05-03T14:07:42Z")

</div>

I just tried the script you sent me two more ways: with ROOT 6.08/06 on the Ubuntu machine and with ROOT 6.06/01 on the SLC6 machine.

The newer version of ROOT produced exactly the .tex you gave me except for numerical differences, and the result when I compiled it was the same: the boxes were fully transparent because their `draw opacity` was again set to 0. When I changed the draw opacity by hand, the boxes appeared with borders as before. The older version of ROOT produced the same result as my python script: visible boxes with borders with no editing.

So I guess something changed between those ROOT versions that made it start adding `draw opacity=0` to the filled objects?

The mystery of why the boxes with `draw opacity=0` are in fact transparent for me but not you remains.

---

<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:** [May 3, 2017, 2:10pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/10 "2017-05-03T14:10:34Z")

</div>

You may have different versions of pgf?

A latex document that outputs the pgf version.

```auto
\documentclass{minimal}
\usepackage{tikz}
\listfiles
\begin{document}

My pgf version is: \pgfversion

\end{document}

```

---

<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:** [May 3, 2017, 2:11pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/11 "2017-05-03T14:11:24Z")

</div>

The history of changes in TeX output is here:

> **[root-project/root](https://github.com/root-project/root/commits/master/graf2d/postscript/src/TTeXDump.cxx)**
>
> The official repository for ROOT: analyzing, storing and visualizing big data, scientifically - root-project/root

I night be that one of the latest explain why it works for me and not for you.

---

<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:** [May 3, 2017, 2:19pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/12 "2017-05-03T14:19:47Z")

</div>

This is the commit where `draw opacity=0` was added: [https://github.com/root-project/root/commit/6d12fc431d7e66a6062c35b3bfc8b675fd2ad77b](https://github.com/root-project/root/commit/6d12fc431d7e66a6062c35b3bfc8b675fd2ad77b). Which is a result of the bug report: [https://sft.its.cern.ch/jira/browse/ROOT-8206](https://sft.its.cern.ch/jira/browse/ROOT-8206)

---

<div class="post-metadata">

**Author:** ![nwoods](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@nwoods](https://root-forum.cern.ch/u/nwoods)\
**Post date:** [May 3, 2017, 2:22pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/13 "2017-05-03T14:22:18Z")

</div>

@ksmith beat me to it but, I see the `draw opacity` change [here](https://github.com/root-project/root/commit/6d12fc431d7e66a6062c35b3bfc8b675fd2ad77b#diff-e8be763eb32f90c5d4dd34b4c186fdaaR291), and indeed the comment says the point was to get rid of an unwanted line on the pattern fill area border! No idea why that affects the whole shape for me but just the border for you. What versions of `pgf` and `tikz` are you using?

---

<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:** [May 3, 2017, 2:25pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/14 "2017-05-03T14:25:16Z")

</div>

Be aware that there are multiple opacity flags:

- `opacity` - Sets both the draw and fill opacity below.
- `draw opacity` - Sets the opacity of paths.
- `fill opacity` - Set the opacity for fills as well as text.
- `text opacity` - Sets the opacity for text overriding the fill opacity.

I believe that the correct option instead of `draw opacity=0` should have been `draw=none`.

---

<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:** [May 3, 2017, 2:27pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/15 "2017-05-03T14:27:19Z")

</div>

@nwoods the question is : Do you have the root version containing the fixes. It seems I fixed the border and transparency issue in the post @ksmith pointed. (sorry to not have looked closely myself I am in something else needing all my brain).

---

<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:** [May 3, 2017, 2:29pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/16 "2017-05-03T14:29:20Z")

</div>

> [@couet](#):
>
> Do you have the root version containing the fixes.

Looks like @nwoods was using 6.08.06 and the “fix” was in 6.08.00:

> [@nwoods](#):
>
> I just tried the script you sent me two more ways: with ROOT 6.08/06 on the Ubuntu machine and with ROOT 6.06/01 on the SLC6 machine.
> 
> The newer version of ROOT produced exactly the .tex you gave me except for numerical differences, and the result when I compiled it was the same: the boxes were fully transparent because their draw opacity was again set to 0.

---

<div class="post-metadata">

**Author:** ![nwoods](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@nwoods](https://root-forum.cern.ch/u/nwoods)\
**Post date:** [May 3, 2017, 2:43pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/17 "2017-05-03T14:43:27Z")

</div>

Thanks for your help, guys.

I’ll see about using a newer ROOT version on the server where I have to actually make these plots. I don’t control the machine but I’m sure I can figure something out.

What I still don’t understand is why `draw opacity=0` seems to make the fills transparent for me too. It seems likely that when I try on a newer ROOT, they will still be gone unless I edit the .tex file and I won’t have gained anything. It’s entirely possible this isn’t a ROOT issue at all; I’m not sufficiently fluent in pgf/tikz to debug much further.

---

<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:** [May 3, 2017, 2:44pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/18 "2017-05-03T14:44:38Z")

</div>

Did you try `draw=none` instead of `draw opacity=0`?

---

<div class="post-metadata">

**Author:** ![nwoods](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/90db22/32.png) [@nwoods](https://root-forum.cern.ch/u/nwoods)\
**Post date:** [May 3, 2017, 2:57pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/19 "2017-05-03T14:57:47Z")

</div>

Yes, and it works. So does my current solution, which is to change `\draw` to `\path`. Either way I have to tinker with the .tex file ROOT gives me, but that’s not so bad. Python regex is easy, and it only has to work for a few months until I graduate ;). Someone who knows these packages better than I do will have to comment on a more robust solution (or if one is even needed – it’s totally possible that the disappearing fills are due to a quirk unique to my setup).

---

<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:** [May 3, 2017, 2:59pm UTC](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623/20 "2017-05-03T14:59:01Z")

</div>

I would propose that `TTexDump` be modified to use `draw=none` then. It appears to be more robust.

[Next page](https://root-forum.cern.ch/t/unwanted-borders-around-fill-areas-when-canvas-is-printed-as-a-tex/24623.md?page=2)
