2

I am trying to create a node which is half one colour half another and I am following the idea presented in this answer: https://tex.stackexchange.com/a/343674/42861

However, no mater what I assign shading angle to I always get a vertical split node.

enter image description here

All my nodes need the same split, so I decided to define a node style:

\tikzstyle{dc-node}=[node-base, shading angle=45, double color fill={AntiqueWhite}{LightBlue}]

Where node-base is basic style all my nodes follows:

\tikzstyle{node-base}=[circle, draw, align=center, font=\footnotesize, minimum size=1.3cm]

The include picture is generated using the following code:

\documentclass[svgnames]{standalone}

\usepackage{tikz} \usepackage{lmodern} \usetikzlibrary{shadows} \usetikzlibrary{shapes} \usetikzlibrary{positioning} \usetikzlibrary{shadings} \tikzset{ double color fill/.code 2 args={ \pgfdeclareverticalshading[% tikz@axis@top,tikz@axis@middle,tikz@axis@bottom% ]{diagonalfill}{100bp}{% color(0bp)=(tikz@axis@bottom); color(50bp)=(tikz@axis@bottom); color(50bp)=(tikz@axis@middle); color(50bp)=(tikz@axis@top); color(100bp)=(tikz@axis@top) } \tikzset{shade, left color=#1, right color=#2, shading=diagonalfill} } }

\tikzstyle{node-base}=[circle, draw, align=center, font=\footnotesize, minimum size=1.3cm] \tikzstyle{dc-node}=[node-base, shading angle=45, double color fill={AntiqueWhite}{LightBlue}]

\begin{document} \begin{tikzpicture} \node[dc-node] (n1) at (0, 0) {N$_1$}; \node[dc-node] (n2) at (2.5, -.5) {N$_2$}; \end{tikzpicture} \end{document}

My expectation was to get a tilt of 45 degress on the split, but clearly I do not get this. Have I missed something?

2 Answers2

4

The order of options can matter.

Put the angle after the creation of the shading:

\tikzstyle{dc-node}=[node-base, double color fill={AntiqueWhite}{LightBlue},
shading angle=45
]

enter image description here

Ulrike Fischer
  • 327,261
2

Yes, the order of options can matter! Do you want another approach via node-like pic? Multi parameters seem to make that more flexible!

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
% #1 and #2 are colors; 
% #3 is node name, to refer later 
% (note: no space in node name)
% #4 is text of the node. It can be empty!
% #5 is rotating angle   
\tikzset{pics/rotating disk/.style args=
{#1/#2/#3/#4/#5}{code={%
\begin{scope}[pic actions,rotate=#5]
\fill[#1] (90:1) arc(90:270:1)--cycle;
\fill[#2] (90:1) arc(90:-90:1)--cycle;
\end{scope}
\path (0,0) node[pic actions,draw,circle,minimum size=2cm] (#3) {#4};
}}}

% [scale=] should be with [transform shape]
\path (0,0) pic{rotating disk=cyan/magenta/A/$A$/45} (2,2) pic[draw=red,scale=.5,transform shape]{rotating disk=violet/yellow/B//-20} (3,-1) pic{rotating disk=green/orange/C/$C$/120} (0,-3) pic{rotating disk=pink!50/cyan!50/N2/$N_2$/-45} (-4,0) pic{rotating disk=pink!50/cyan!50/N1/$N_1$/-45}; \draw (A)--(B); \draw[->] (A) -| (B); \draw[stealth-] (C.30) .. controls +(-120:1) and +(45:2) .. (B); \end{tikzpicture} \end{document}

Black Mild
  • 17,569