What is the difference between the TikZ key-value pairs draw=none and draw opacity=0? Are they functionally equivalent, or are there situations in which one should be preferred over another? Similarly, what is the difference between fill=none and fill opacity=0?

  • I once had a case where I wanted to print 2 versions of a document: with and without labels. The first thing I did was text opacity=0. Although nothing was visible in the PDF file, fractions of the labels appeared in the printed version, so be careful ;) Aug 18, 2012 at 17:54

2 Answers 2


draw=none (which is equal to \path command) actually causes TikZ to throw away the constructed path and the bounding box is not disturbed (Nonsense, it does change the bounding box but only line width is ignored. Thanks to @Fritz for catching this stupidity).

draw opacity=0 however causes the path to be drawn with no ink so the bounding box gets updated with line width option in effect, so the line style matters for the bounding box calculation.

\draw (0,0) rectangle (3,3);
\draw[opacity=0,line width=1cm] (0,0) rectangle (3,3); % Enlarge the bounding box 

\pgfsetlinewidth{5cm}     % this has no effect
\pgfpathlineto{\pgfpoint{4cm}{4cm}} % this updates the known max x,y coordinates!!
\pgfusepath{}                       % even though it's thrown away. 

\pgfpathlineto{\pgfpoint{10cm}{10cm}} % Nothing happens

\draw[dashed,thin] (current bounding box.north east) rectangle (current bounding box.south west);

enter image description here

  • @GonzaloMedina Both answers are great -- just what I was looking for. I decided to accept @percusse's answer only because I was originally slightly more interested in draw; I wish I could accept both answers. Aug 18, 2012 at 20:00
  • The beginning of this answer "draw=none [...] causes TikZ to throw away the constructed path and the bounding box is not disturbed" is a bit misleading. The bounding box is indeed disturbed, if the path itself (not the line width) protrudes from the bounding box. In your example \path[line width=4cm] (0,0) rectangle (3,6); would actually modify the bounding box, despite it not drawing. Thus the only difference between draw=none and draw opacity=0 is that the line width has no effect with the former. For "hypothetical curves" you would use the pgfinterruptboundingbox environment.
    – Fritz
    Aug 22, 2012 at 21:23
  • @Fritz It's not misleading, it's flat out wrong :) Apparently, I didn't do enough experiments and jumped to conclusions. Thanks for the catch. I'll update it as soon as possible.
    – percusse
    Aug 22, 2012 at 21:33

filling opacity applies not only to filling operations, but also to also applies to text and images; the following example shows a case in which fill=none and fill opacity=0 (I actually used fill opacity=0.2 just to make the text visible) produce different results; fill=none has no effect on the node label, but fill opacity=<value> will affect the text:



\fill[olive] (0,0) rectangle (3,2);
\node[fill opacity=0.2] at (3,2) {\huge B};
\node[fill=none] at (0,0) {\huge A};


enter image description here

  • Thanks! It seems like a strange design choice to have fill opacity also affect the text opacity; why not leave that altogether to text opacity? Aug 18, 2012 at 17:22
  • @HenryDeYoung no; they are not completely equivalent; I was composing some examples, but percusse has answered this part now. Aug 18, 2012 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .