This is very closely related to a question about highlighting the overlap between circular nodes at Highlight overlap between nodes and draw arrow from node edge. But there is a new angle: how to generalize this to ellipses (and I suppose other shapes, but I care about ellipses for the moment).
You might expect that the following code would fill in the overlap between the ellipses with green:
\documentclass{article}
\usepackage{tikz}
\newcommand*{\MyRadius}{7cm}
\begin{document}
\def\A{(0,0) ellipse [minimum width = 2*\MyRadius, minimum height = \MyRadius]}
\def\B{(8,0) ellipse [minimum width = 2*\MyRadius, minimum height = \MyRadius]}
\begin{tikzpicture}
\node[draw, shape=ellipse, minimum width=2*\MyRadius, minimum height=\MyRadius, ultra thick] (A) at (0,0) {};
\node[draw, shape=ellipse, minimum width=2*\MyRadius, minimum height=\MyRadius, ultra thick] (B) at (8,0) {};
\begin{scope}
\clip \A;
\fill[green, opacity=0.2] \B;
\end{scope}
\end{tikzpicture}
\end{document}
But it doesn't. I also tried specifiying the height and width of the ellipses in (x, y) format, instead of in square brackets, but that is even worse (produces an error).
Best Answer
Note that there is a difference between the path
ellipse
, which has parametersx radius
andy radius
, and the shapeellipse
, which is not predefined but to be found in theshapes.geometric
library and for whichminimum width
is an "x
diameter". Once this is taken into account you can use the same type of code as you used for circles:Adding your node connecting like operations as your circle case now works as expected too: