# Tikz sub-triangle fill

I am quite new to tikz, but I'd like to improve my picture. It's pretty simple in theory: I have a tree represented as a triangle with two subtrees, delimited by a curved path, and I'd like the left sub-tree to be of different color from the right one.

This is my current code:

\begin{tikzpicture}
% NODES
\node (r0) at ( 0.0,  0.0) {}; % root
\node (s0) at (-3.0, -4.0) {}; % extreme
\node (s1) at ( 3.0, -4.0) {}; % extreme
\node (si) at (-1.0, -4.0) {}; % inside

% DRAW TREE
\fill[fill=gray!20] (r0.center)--(s0.center)--(s1.center);
\path[draw] (r0)--(s0);
\path[draw] (s0)--(si);
\path[draw] (si)--(s1);
\path[draw] (s1)--(r0);

% DRAW NODES
\draw[color=black, fill=white] (r0) circle (.15);
\draw[color=black, fill=gray]  (s0) circle (.15);
\draw[color=black, fill=gray]  (s1) circle (.15);
\draw[color=black, fill=red]   (si) circle (.15);

% DRAW PATH FROM ROOT
\draw[color=black, line width=1.5pt,densely dotted]
(r0) to [out=300, in=130] (si);

\end{tikzpicture}


I don't know how to create the two filled figures. I've tried "merging" the last root-to-node curved shape in the \fill, but it won't do what I want:

\draw[draw,fill=red] (r0)--(s0)--(si) to [out=110, in=290] (r0);


Any hints are welcome!

• It isn't clear what it is that you want. Could you try to make it clearer? – Seamus Mar 7 '16 at 15:48
• It's essential that you clearly describe the expected output. In this case it isn't really clear what you are talking about. The next time you could just use an image editor program to quickly point out which areas you want to fix, or add some labels to the nodes and say which polygones/shapes you want filled. – Bakuriu Mar 7 '16 at 19:45

Simply fill the whole triangle with one color, so you can then draw a path to fill for the other side.

## Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\tikzset{
circ/.style={circle, fill=black, inner sep=2pt, node contents={}}
}

\begin{document}
\begin{tikzpicture}
% coordinates
\coordinate (r0) at (0,0);
\coordinate (s0) at (-3,-4);
\coordinate (si) at (-1,-4);
\coordinate (s1) at (3,-4);
%
\filldraw[draw=black, fill=gray!20] (r0) -- (s0) -- (si) -- (s1) -- cycle;

\filldraw[draw=black, fill=red, line width=1.5pt,densely dotted]
(r0) to[out=300, in=130] (si) -- (s1) -- cycle;

\draw[black, fill=white] (r0) circle (.15);
\draw[black, fill=gray]  (s0) circle (.15);
\draw[black, fill=gray]  (s1) circle (.15);
\draw[black, fill=red]   (si) circle (.15);

\end{tikzpicture}
\end{document}


Here's one way to do it. I'm using the backgrounds library to avoid drawing over the nodes, but using the nodes' coordinates.

I've removed your original command that draws the background of the triangle to instead draw both halves seperately. Also, I'm using coordinates like (si.center) to truly fill the entire triangle.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
% NODES
\node (r0) at ( 0.0,  0.0) {}; % root
\node (s0) at (-3.0, -4.0) {}; % extreme
\node (s1) at ( 3.0, -4.0) {}; % extreme
\node (si) at (-1.0, -4.0) {}; % inside

% DRAW TREE
\path[draw] (r0)--(s0);
\path[draw] (s0)--(si);
\path[draw] (si)--(s1);
\path[draw] (s1)--(r0);

% DRAW NODES
\draw[color=black, fill=white] (r0) circle (.15);
\draw[color=black, fill=gray]  (s0) circle (.15);
\draw[color=black, fill=gray]  (s1) circle (.15);
\draw[color=black, fill=red]   (si) circle (.15);

% DRAW PATH FROM ROOT
\draw[color=black, line width=1.5pt,densely dotted]
(r0) to [out=300, in=130] (si);

% fill halves of triangle
\begin{scope}[on background layer]
\fill[green!20!white,on background layer] (r0) to [out=300, in=130] (si) -- (si.center) -- (s0.center) -- (r0.center) -- cycle;
\fill[blue!20!white,on background layer] (r0) to [out=300, in=130] (si) -- (si.center) -- (s1.center) -- (r0.center) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}