# Color fade a line in tikzpicture

I had already a similar question. I know now how to color fade rectangles. But I was trying now for almost an hour and I couldn't figure out how to do a fading for a line.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[remember picture,overlay]

\draw[line width=4pt,orange]
([yshift=-62pt]current page.north west) -- +(14cm,0pt);
\draw[orange,line width=1pt]
([yshift=-175pt,xshift=+14cm]current page.north west) -- +(5.1cm,0pt);

\end{tikzpicture}
\end{document}


I want the lines to fade from left orange to right white.

• A line can be be considered as a very thin rectangle... Dec 8, 2014 at 22:29
• @PaulGaborit of course I tried that, but it seems there is a minimum width for a rectangle. At least I couldn't get it as thin as I wanted Dec 8, 2014 at 22:35
• I meant miminum height Dec 8, 2014 at 22:47

A line can be be considered as a very thin rectangle...

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[remember picture,overlay]
\path[left color=orange,right color=white]
([yshift=-62pt]current page.north west)
+(0,-2pt) rectangle +(14cm,2pt);

\path[left color=orange,right color=white]
([yshift=-175pt,xshift=+14cm]current page.north west)
+(0,-.5pt) rectangle +(5.1cm,0.5pt);
\end{tikzpicture}
\end{document}

• my apologies, I did it with a \node don't know if that was the reason why it wasn't working Dec 8, 2014 at 23:22
• @AdrianPfeifle A node uses implicitly inner sep distance (initially .3333em). If you want to use a node, try it with inner sep=0. Dec 8, 2014 at 23:26
• thanks for the hint, now what I tried before is also working Dec 8, 2014 at 23:28
• Hey Paul, any ideas how to integrate your MWE with the one here tex.stackexchange.com/questions/376873/… ? Jun 26, 2017 at 15:24