3

I want to add to intersecting circles together in latex and remove that area from an even larger circle. My code is as follows:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikzsymbols}
\usetikzlibrary{shapes,backgrounds,patterns}

\title{picture}
\author{john }
\date{April 2016}

\begin{document}


\def\cutThis{(3.5,0.7) circle (1cm) (5,0) circle (1cm)}

\begin{tikzpicture}

\fill[yellow, even odd rule] (4,0) circle (2cm) \cutThis;

\end{tikzpicture}


\maketitle

\section{Introduction}

\end{document}

However this isnt working as the area where the two circles intersect is yellow. It would be great if someone could help me out.

John
  • 31

1 Answers1

2

The easiest method would just be to fill the circles with white after filling the yellow circle. If that's not an option, things are less straightforward but the following more-or-less works. That is, it works but you may get artefacts, depending on your viewer. (I do as you see in the screenshot.)

\documentclass[border=10pt,tikz,multi]{standalone}

% code for inverse clipping from Paul Gaborit's answer at http://tex.stackexchange.com/a/59168/

\tikzset{%
  invclip/.style={%
    clip,insert path={%
      {%
        [reset cm]
        (-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt)
      }%
    }%
  },
}
\begin{document}
\begin{tikzpicture}
  \begin{scope}
    \begin{pgfinterruptboundingbox}
      \path[invclip] (3.5,0.7) circle (1cm) (5,0) circle (1cm)  (3.5,0.7) circle (1cm);
    \end{pgfinterruptboundingbox}
    \fill[yellow, even odd rule] (4,0) circle (2cm)  (3.5,0.7) circle (1cm);
  \end{scope}
\end{tikzpicture}
\end{document}

inside out

EDIT

For Venn diagrams, there are some tailor-made packages available which are designed to make this easy. venndiagram is TikZ-based, while venn is based on MetaPost.

Because these are designed for Venn diagrams they do assume that the outermost area is a rectangle. I'm not sure whether this is an issue in this case or not. In any case, here's a couple of examples using the first package to illustrate its use with 2 sets and 3 sets.

\documentclass[border=10pt,tikz,multi]{standalone}
\usepackage{venndiagram}
\begin{document}
\begin{venndiagram2sets}[labelA={}, labelB={}, shade=yellow]
  \fillNotAorB
\end{venndiagram2sets}
\begin{venndiagram3sets}[labelA={}, labelB={}, labelC={}, shade=yellow]
  \fillNotABC
\end{venndiagram3sets}
\end{document}

This produces

not-A and not-B

and

not-A and not-B and not-C

Adapting the second diagram slightly

\begin{venndiagram3sets}[labelA={}, labelB={}, labelC={}, shade=yellow, tikzoptions={draw=none}]
  \fillNotABC
\end{venndiagram3sets}

we can obtain

not-A and not-B and not-C undrawn

cfr
  • 198,882
  • thanks alot for your help. What i'm really trying to achieve is a ven diagram where all 3 circles have different shading patterns. The problem is that when I fill the big one with a pattern, it shades the small ones at the same time - so filling with white isn't an option. Is this the simplest way to achieve this? – John Apr 22 '16 at 00:32
  • Probably the simplest way would be to use one of the packages available for drawing Venn diagrams ... ;). – cfr Apr 22 '16 at 00:48
  • @John For example, venn or venndiagram. The latter was broken, but has probably been fixed by now. – cfr Apr 22 '16 at 01:40