I want to parameterize node creation in a foreach. The creation prozess was solved in: Cut part of radialshading out as node shape circular sector

I think the substitution in the foreach has a recognition problem, but otherwise, why get the first node what is expected, i.e. content (\monname) and the shading(rad1)?

Knows anyone a solution?

   % from https://tex.stackexchange.com/a/127045/121799
   \tikzset{use path/.code=\tikz@addmode{\pgfsyssoftpath@setcurrentpath#1}}

\tikzset{my radial shader/.code args={#1 with radius #2}
                             \pgfdeclareradialshading{#1}%shading name
                                                     {\pgfpoint{0}{0}}%center point pgfman301a,p.1083
                                                     {rgb(0pt)=(1.00,0.00,0.00); %color specification
                                                      rgb(\rone pt)=(0.60,1.00,0.00);
                                                      rgb(\rtwo pt)=(0.30,1.60,1.00);
                                                      rgb(#2)=(0.00,0.30,1.50) %extent of the circle
                                                     }%end color specification
                            }%end .code args
}%end tikzset

\tikzset{shape circlesec/.style={
        line width=1.1pt,
        shape=circular sector,
        circular sector angle=30,
        shape border uses incircle,
        anchor=sector center,%to get a circle!
        minimum size = 6.6cm,%

\foreach \monname / \nodename / \borderrotate in {jan/"\jan"/90,feb/"\feb"/0,maerz/"\maerz"/-165} {%
   \node [save path=\nodename, %this line must create "\jan","\feb" etc.
   %\typeout{monname:\monname, nodename: \nodename}%doesn't work
   %    \node [save path=\jan,
          style=shape circlesec,
          shape border rotate=\borderrotate,
   %      shape border rotate=-165,
      (\monname) at (0,0) {\monname};%\nodename error undef ctrl seq
   %  (jan) at (0,0) {};%semicolon before \begin{scope} error
   \begin{scope}[on background layer]
      \path    let \p1=($(\monname.arc center)-(\monname.sector center)$),
   %  \path    let \p1=($(jan.arc center)-(jan.sector center)$),
                   \n1={veclen(\y1,\x1)} in 
         [my radial shader={rad1 with radius \n1}];%rad1==param1, \n1 param2 (radius \node \monat)

      \clip[use path=\nodename];               
   %  \clip[use path=\jan];               
}%end foreach

Shading will not be assigned

1 Answer 1


There are expansion issues in your code. Basically you cannot store the path in a macro in the way you try to do that. Rather than addressing these issues, I'd propose going another way

\tikzset{shade radial/.code={%
          color four radial/.cd,% I know "four color radial" sounds better but cfr should be acknowledged here
color four radial/.cd,  
shade radial color/.code n args={2}{\colorlet{cfradialcolor#1}{#2}},
shade radial color={1}{black},
shade radial color={2}{black},
shade radial color={3}{white},
shade radial color={4}{white},
cfradial/.style={/tikz/path picture={
\pgfdeclareradialshading[cfradialcolor1,cfradialcolor2,cfradialcolor3,cfradialcolor4]{cfradial}%shading name see pgfmanual 3.01a, p. 1083
                            {\centerpoint}%center point 
                            {color(0pt)=(cfradialcolor1); %color specifications
                             color(\rone pt)=(cfradialcolor2);
                             color(\rtwo pt)=(cfradialcolor3);
                             color(\radius)=(cfradialcolor4) %

\tikzset{shape circlesec/.style={
        line width=0.1pt,
        inner xsep=0pt,
        inner ysep=0pt,
\foreach \monname/\borderrotate in {jan/90,feb/0,maerz/-165} {%
\node [shape=circular sector, 
       style=shape circlesec,
       inner sep=0cm,
       shade radial={
        shade radial color={1}{clr1},
        shade radial color={2}{clr2},
        shade radial color={3}{clr3},
        shade radial color={4}{clr4}
       circular sector angle=30,
       shape border uses incircle,
       shape border rotate=\borderrotate,
       anchor=sector center,inner sep=-2mm,%
       minimum size = 6.6cm,
   (\monname) at (0,0) {\monname};}

enter image description here

  • The node now is fully parameterizable, thank you.
    – gizeh
    Jan 11, 2019 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.