5

I've just gotten into the tikz package, and am using tikzpicture to do some work with graphs and complexes on them. I want to be able to fill in certain areas of the graphs. I've found what I want, but there is a thing that's bugging me (see the code and picture).

 \begin{tikzpicture}
  \tikzstyle{vertex}=[draw,circle, fill = black, inner sep = 1.5pt] 
  \node[vertex] (1) [label = right:$a$] at (0,0) {};
  \node[vertex] (2) [label = right:$b$] at (3,0) {};
  \node[vertex] (3) [label = right:$c$] at (1,1.5) {};
  \node[vertex] (4) [label = above:$d$] at (1,3) {};
  \node[vertex] (5) [label = below:$e$] at (0,-2) {};
  \node[vertex] (6) [label = below:$f$] at (2,-2) {};
  \draw[fill=gray] (3) to (4) to [out=180,in=90] (-1.5,0) to [out=-90,in=135] (5) to [out=90,in=-90] (-0.5,0) to [out=90,in=180] (3);
\end{tikzpicture}

enter image description here

At the edge cd, there is a strip that is not filled in, while I want it to be. Are there any suggestions or solutions to this problem? Have I missed something? Can I do anything differently? Thanks in advance.

6

I suppose, that you like to obtain the following picture:

enter image description here

From code below you can see, that the coordinates are determined by .center. Without this it is considered one of anchors on node's shape border. To be filled area under nodes, I also use `background library.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{backgrounds}

    \begin{document}
 \begin{tikzpicture}
  \tikzstyle{vertex}=[draw,circle, fill = black, inner sep = 1.5pt]
  \node[vertex] (1) [label = right:$a$] at (0,0) {};
  \node[vertex] (2) [label = right:$b$] at (3,0) {};
  \node[vertex] (3) [label = right:$c$] at (1,1.5) {};
  \node[vertex] (4) [label = above:$d$] at (1,3) {};
  \node[vertex] (5) [label = below:$e$] at (0,-2) {};
  \node[vertex] (6) [label = below:$f$] at (2,-2) {};
\scoped[on background layer]
  \draw[fill=gray] (3.center) to (4.center) to [out=180,in=90] (-1.5,0) to [out=-90,in=135] (5.center) to [out=90,in=-90] (-0.5,0) to [out=90,in=180] (3.center);
\end{tikzpicture}
    \end{document}
3

Another way

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{quotes}

\begin{document}
 \begin{tikzpicture}

  \path coordinate["$a$"  right] (1)  at (0,0) 
        coordinate["$b$"  right] (2)  at (3,0) 
        coordinate["$c$"  right] (3)  at (1,1.5) 
        coordinate["$d$"  above] (4)  at (1,3) 
        coordinate["$e$"  below] (5)  at (0,-2) 
        coordinate["$f$"  below] (6)  at (2,-2) ;

  \draw[fill=gray] (3) to (4) 
                       to [out=180,in=90] (-1.5,0) 
                       to [out=-90,in=135] (5) 
                       to [out=90,in=-90] (-0.5,0) 
                       to [out=90,in=180] (3);

  \foreach \c in {1,...,6}{\fill (\c) circle (1.5 pt); }

\end{tikzpicture}
 \end{document}

enter image description here

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.