2

So I am trying to do something more complicated, but for the sake of trying to understand the problem I simplified the issue

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node (x) at (0,0) {};
\node (y) at (1,0) {};
\node (z) at (0,1) {};
\draw[fill=blue] (x) -- (y) -- (z) -- (x);
\end{tikzpicture}

\end{document}

screenshot

I get just a triangle outline with vertices, but no fill. I want to fill a region defined by some nodes of a graph, but I cannot seem to get it to work. I am very much so a novice at tikz, so any assistance with identifying the issue or how to get around it is appreciated.

1 Answer 1

3

You have several options, including:

1: Specify what part of the node should be the corner of the filled triangle:

\draw[fill=blue] (x.center) -- (y.center) -- (z.center) -- (x.center);

2: Use coordinates instead of nodes

\coordinate (x) at (0,0);
\coordinate (y) at (1,0);
\coordinate (z) at (0,1);

3: Use the coordinate shape for nodes (p. 229 of the PGF Documentation):

\node[coordinate] (x) at (0,0) {};
\node[coordinate] (y) at (1,0) {};
\node[coordinate] (z) at (0,1) {};

See also §17.11 Connecting Nodes: Using Nodes as Coordinates from the PGF Documentation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .