I have made a graph with TikZ and now I would like to apply a shading to some of the nodes but I can't seem to find out how to do that.
This doesn't work:
\documentclass{article}
\usepackage{tikz}
\tikzset{every node/.append style={minimum size=.7cm, draw,circle,font=\sffamily\Large\bfseries,inner sep=0.05cm}}
\begin{document}
\begin{tikzpicture}[sh/.style={shade,shading=axis,shading angle=45,left color=red,right color=green}]
\node (x1) {$x_1$};
\node[node distance=3cm,right of=x1] (x2) {$x_2$};
\node[node distance=3cm,right of=x2] (x3) {$x_3$};
\node[node distance=1cm,below of=x1] (1) [sh] {};
\node[node distance=1cm,below of=x2] (2) [sh] {};
\node[node distance=1cm,below of=x3] (3) [sh] {};
\node[node distance=1.5cm,below of=1] (4) {};
\node[node distance=1.5cm,below of=2] (5) {};
\node[node distance=1.5cm,below of=3] (6) {};
\foreach \from/\to in {x1/1,x2/2,x3/3,1/4,2/5,3/6,4/5,5/6} \draw (\from) -- (\to);
\end{tikzpicture}
\end{document}
shading angle=45
is ignored? To get a rotated linear shading, you'll have to usetop color
andbottom color
instead ofleft color
andright
color, and theshading angle
parameter needs to be provided last.top
andbottom
?left
andright
will also work, providedshading angle
is used last.