1

enter image description here

I want to draw the above figure, I have the preliminary code below, how can I edit the following code to have the effect of half shaded node?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usetikzlibrary{fit,positioning,automata,calc}
\begin{document}
\begin{tikzpicture} 
\tikzstyle{main}=[circle, minimum size = 10mm, thick, draw =black!80, node distance = 16mm]
\node[main] (pzd) [label=below:$y$] { }; 
\end{tikzpicture}
\end{document}
sunxd
  • 215
  • 2
    Possibly duplicate: https://tex.stackexchange.com/a/241544/31034 –  Jun 27 '20 at 11:52
  • 1
    It is more correct for your MWE to use \begin{tikzpicture} \tikzstyle{main}=[circle, minimum size = 10mm, thick, draw =black!80, node distance = 16mm] \node[main] (pzd) [label=center:$\mathbf{y}$] { }; \end{tikzpicture} – Sebastiano Jun 27 '20 at 11:54

2 Answers2

0

as @feraheza pointed out, one could use the background library, and add

\begin{scope}[on background layer]
\fill[fill=gray!25] (y.225) arc [start angle=225, end angle=405, radius=5mm];
\end{scope} 

below the node in definition in question.

sunxd
  • 215
0

See my answer of duplicated question: https://tex.stackexchange.com/a/551380/201158

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{calc}
\makeatletter
\tikzset{
  prefix after node/.style={
    prefix after command={\pgfextra{#1}}
  },
  /semifill/ang/.store in=\semi@ang,
  /semifill/ang=0,
  semifill/.style={
    circle, draw,
    prefix after node={
      \typeout{aaa \semi@ang}
      \let\nodename\tikz@last@fig@name
      \fill[/semifill/.cd, /semifill/.search also={/tikz}, #1]
        let \p1 = (\nodename.north), \p2 = (\nodename.center) in
        let \n1 = {\y1 - \y2} in
        (\nodename.\semi@ang) arc [radius=\n1, start angle=\semi@ang, delta angle=180];
    },
  }
}
\makeatother

\begin{document} \begin{tikzpicture} \node[semifill={gray,ang=60}] {$y$}; \end{tikzpicture} \end{document}

enter image description here

ZhiyuanLck
  • 4,516