Home > tikz pgf > Tikz: use opacity for fill, yet leave draw (lines) untouched

# Tikz: use opacity for fill, yet leave draw (lines) untouched

December 21Hits:4

When I use the tikz key opacity for a polygon in a tikzpicture, it applies to the drawn fill as well as to the draw lines.

I would like to have it this way that the lines remain untouched by the opacity key, so that they behave as if they had opacity=1.

(What I do now is redraw the polygon with fill=none, but that is a crippled solution to the problem).

You can specify the fill opacity separately form the draw opacity. In the first example below I used opacity and in the second I used fill opacity which will only affect the fill and not the draw.

## Note:

• As pointed out by Martin Scharrer: Specifying \opacity=<x> affects the fill, draw and text so is equivalent to saying fill opacity=<X>, draw opacity=<X>, text opacity=<X>.
• fill opacity applies not only to the fill, but also applies to text. To override this behavior, you can separately set the text opacity which applies only to the text labels. So, apply text opacity=1 to ensure that opacity is not applied to the text.

## Code:

\documentclass[border=3pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [ultra thick, draw=black, fill=yellow, opacity=0.2]
(0,0) -- (0,1) -- (1,1) -- cycle;
\end{tikzpicture}
\begin{tikzpicture}
\draw [ultra thick, draw=black, fill=yellow, fill opacity=0.2]
(0,0) -- (0,1) -- (1,1) -- cycle;
\end{tikzpicture}
\end{document}



## Related Articles

• ### Tikz: use opacity for fill, yet leave draw (lines) untouchedDecember 21

When I use the tikz key opacity for a polygon in a tikzpicture, it applies to the drawn fill as well as to the draw lines. I would like to have it this way that the lines remain untouched by the opacity key, so that they behave as if they had opacity

• ### Tikz matrix does not allow me to \draw line between nodesOctober 5

If I want to put a line between nodes 1-1 and 2-2: \begin{tikzpicture} \matrix (magic) [matrix of math nodes, left delimiter=\lvert, right delimiter=\rvert,column sep=4pt,row sep=4pt] { \draw (0,0) circle (5pt); & \fill (0,0) circle (2pt); & \fill

• ### draw lines in front of nodes rather than behind themOctober 23

I want to draw a thick semi-transparent arrow path in front of nodes, but it seems like I'm stuck drawing behind them: How can I draw a path in front of the nodes? \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{shapes, shadows, position

• ### tikz picture: draw opacity vs fill opacity?November 6

\documentclass{article} \usepackage{tikz} \begin{document} \pagenumbering{gobble} \hskip-1.25in \begin{tikzpicture}[thick,fill opacity=.4,draw opacity=1] %\draw[step=1cm] (-9,-9) grid (9,9); %\filldraw[fill=black,fill opacity=1] (0,0) circle (.5mm);

• ### Setting camera projection angle in tikz to enhance the depth perception when drawing 3D figuresJune 5

First please see the following example using MATLAB drawing command >>surf(membrane); We can adjust the camera angle using MATLAB's built-in command camproj, the effects are as follows: It is like the effect of adjusting the camera angle in Paraview

• ### Drawing line "on top" in tikzJune 15

I have a tikz graphic which I'm using in two different final documents. It contains a line-crossing where I've needed to specify which line was on-top, via surrounding it with a white-coloured "buffer", akin to breaking a line when drawing a bra

• ### What is the difference between Opacity and Fill on a photoshop layer?May 3

The opacity and fill settings on a layer in Photoshop seem to do the same thing. What is the difference? --------------Solutions------------- When we set the Opacity value for a selected layer, the change applies to the entire layer. This means that

• ### tikz: draw line thickness less than 0.1 mmOctober 7

In tikz is it possible to draw lines thinner than 0.1 mm? ultra thin option gives line thickness 0.1 mm. I want to draw a pattern using line thickness 0.07 mm. --------------Solutions------------- You can specify the line width. Here is a zoomed in v

• ### TikZ: draw lines connecting border of shapesNovember 13

Being new to TikZ, I am trying to draw several (labeled) circles which are connected by lines. In its simplest form, I am doing this via \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw (0,0) circle [radius=0.5] no

• ### Draw lines over a matrixSeptember 6

I have the following code to print a matrix: \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture}[cell/.style={rectangle,draw=black}, nodes in empty cells] \matrix[ matrix of math nodes, row sep =-\pg

• ### Tikz get rid of the rest of a line after intersectionJuly 9

I have created the following figure: \documentclass[border=18pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} \begin{scope}[>=latex] \draw [->] (-3,0) -- (3,0); \draw [->] (0,-1.5) -- (0,6.5); \end{scope} \filldraw [black] (

• ### Drawing lines half the thickness of the default thickness January 8

In the following code, two triangles are drawn - one is the reflection of the other across the line y=x. I would like to have a line, with the command \draw[loosely dash dot], drawn either half or a third the thickness of the dashed lines in triangle

• ### Draw lines inside a matrixApril 6

I have the following code to draw a matrix: \documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \begin{tikzpicture}[cell/.style={rectangle,draw=black}, nodes in empty cells] \matrix[ matrix of math nodes, row sep =-\pgf

• ### Drawing lines to the correct circleDecember 1

I have the following code \def\aes{in*0.75}%% \begin{tikzpicture}[scale=0.34mm] \coordinate (A) at (0,0); \coordinate (B) at ($(A)+(30:4\aes)$); \coordinate (C) at ($(B)+(-90:2.5\aes)$); \draw[line width=2pt,gray!60,postaction={draw,black,dashed,line

• ### How to draw line passing three points in xy-planeFebruary 3

My question is , In my MWE i would like to draw a line passing through three points (-100, 700) , (100, 600) and (300, 500). further how can i label that line i mean how can i write the mathematical equation of line near by it. Here what i have done

• ### How to draw lines between nodes that point at the node center, but stop at the nodes edgeFebruary 4

I'm drawing nodes on a circle and switched from drawing lines based on coordinates to drawing them based on named nodes. The problem now is, that with the following code the lines stop at the edges of the nodes, but don't point at the center. How do

• ### Draw lines by specifying angles?February 8

I'd like to be able to draw lines in LaTeX by specifying an angle, rather than specifying it like so \put(0,0){\line(2,1){3}} Is this possible? I've looked at tikz and tikz-euclid. I've even tried installing tikz-euclid, but I couldn't even do that (

• ### Photoshop Pen Tool: draw lines in a vector maskMay 22

How could I draw lines in a vector mask ? I want to reach the same effect like if I were working with shapes, because the image needs to be vector and scalable. For example, if I draw an elipse, then fill a layer with white and reveal vector mask ass

• ### How to draw lines between user draggable points?July 3

I want to create a triangle using three different points on the SurfaceView using OpenGL. Line indications between the points with one color and fill the triangle with different color. I want to pull those points from existing place to the user desir

• ### In a ListPlot of LinearModelFit, Fill to the regression lineSeptember 30

In the help for LinearModelFit, the regression line can be added to the scatter plot like this: Show[ListPlot[data], Plot[lm[x], {x, 0, 5}]] Is it possible to fill from the points to the regression line? This can illustrate the distance whose sum of