# tikzpicture: best practices for filling in shaded area between multiple curves

Using the minimal working example below I've been able to make this image with tikzpicture:

I would like to shade in the regions between the circle and the two outer elipses like this:

Using Graphing y=x^2 and y=x it's possible to do this in a slightly botched solution by first filling between the two ellipses and then filling in the remaining area between the circle and the vertical line created by filling in the ellipses. This feels like it is not "best practice". Is there a more clever way to do this?

Here is the minimal working example use to generate the first image

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
%draw the circle
\draw (0,0) circle(1);
\draw plot[domain=pi:2*pi] ({cos(\x r)},{.2*sin(\x r)});
\draw[dashed] plot[domain=0:pi] ({cos(\x r)},{.2*sin(\x r)});

%draw the upper ellipse
\draw plot[domain=pi:2*pi] ({0.864*cos(\x r)},{.2*sin(\x r)+.5});
\draw[dashed] plot[domain=0:pi] ({0.864*cos(\x r)},{.2*sin(\x r)+.5});

%draw the lower ellipse
\draw plot[domain=pi:2*pi] ({0.864*cos(\x r)},{.2*sin(\x r)-.5});
\draw[dashed] plot[domain=0:pi] ({0.864*cos(\x r)},{.2*sin(\x r)-.5});
\end{tikzpicture}
\end{document}

• Using trig functions to draw your ellipses is not the best idea, in my opinion. You could draw them with simple TikZ ellipses. Then use some clips to fill in. Commented Sep 4, 2022 at 16:42

As stated in my comment, using ellipses and clips seems easier to me.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}

%fills
\begin{scope}
\fill [blue,opacity=0.6] (-1.72,1) arc[start angle = -180, end angle = 0,x radius=1.72,y radius=0.4] -- (2,1) |- (1.72,-1) arc[start angle = 0, end angle = -180,x radius=1.72,y radius=0.4] -- (-2,-1) |- cycle;
\end{scope}

% Upper ellipse
\draw (-1.72,1) arc[start angle = -180, end angle = 0,x radius=1.72,y radius=0.4];
\draw[dashed] (-1.72,1) arc[start angle = 180, end angle = 0,x radius=1.72,y radius=0.4];

% Middle ellipse
\draw (-2,0) arc[start angle = -180, end angle = 0,x radius=2,y radius=0.5];
\draw[dashed] (-2,0) arc[start angle = 180, end angle = 0,x radius=2,y radius=0.5];

% Lower ellipse
\draw (-1.72,-1) arc[start angle = -180, end angle = 0,x radius=1.72,y radius=0.4];
\draw[dashed] (-1.72,-1) arc[start angle = 180, end angle = 0,x radius=1.72,y radius=0.4];

% Dots