3

EDIT This is not a Venn diagram but an Euler diagram.

ORIGINAL QUESTION I want to draw a Venn Diagram for an absolute complement. However, I'm having problems with the background filling. The M circle needs to be without fill (white). How can I achieve that?

This is my Venn-diagram so far:

enter image description here

And this is the MWE:

\documentclass{scrbook}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,backgrounds,fit}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}
        \def\firstcircle{(0,0) circle (1.5cm)}
        \def\secondcircle{(0:0.5cm) circle (0.8cm)}
        
        \colorlet{circle edge}{red!50}
        \colorlet{circle area}{red!20}
        
        \tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
            outline/.style={draw=circle edge, thick}}
        
        \setlength{\parskip}{5mm}
        \begin{scope}
            \fill[filled] \firstcircle;
            \clip \secondcircle;
        \end{scope}
        \draw[outline] \firstcircle node [xshift=-20pt] {$G$};
        \draw[outline] \secondcircle node {$M$};
        \node[anchor=south] at (current bounding box.north) {$\overline{M}$};
    \end{tikzpicture}
\end{document}

4
  • 3
    A bit of pedantry (and something that I only learned when I taught this in a math for liberal arts majors class): What you drew was an Euler diagram and not a Venn diagram. A Venn diagram always has partially overlapping circles with coloring used to indicate whether the relation between the sets is a union, intersection, etc. Euler diagrams use spatial positioning to show the relations between sets.
    – Don Hosek
    Commented Dec 8, 2020 at 20:38
  • 1
    More on that topic here: en.wikipedia.org/wiki/Euler_diagram
    – Don Hosek
    Commented Dec 8, 2020 at 20:39
  • 1
    (And my shameful confession: when I taught this the first time, I got it wrong.)
    – Don Hosek
    Commented Dec 8, 2020 at 20:40
  • Thank you so much for that comment @DonHosek.
    – NilsK
    Commented Dec 8, 2020 at 21:07

3 Answers 3

6

You can simply add fill=white when you draw the second circle.

\documentclass{scrbook}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,backgrounds,fit}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}
        \def\firstcircle{(0,0) circle (1.5cm)}
        \def\secondcircle{(0:0.5cm) circle (0.8cm)}
        
        \colorlet{circle edge}{red!50}
        \colorlet{circle area}{red!20}
        
        \tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
            outline/.style={draw=circle edge, thick}}
        
        \setlength{\parskip}{5mm}
        \begin{scope}
            \fill[filled] \firstcircle;
            \clip \secondcircle;
        \end{scope}
        \draw[outline] \firstcircle node [xshift=-20pt] {$G$};
        \draw[outline, fill=white] \secondcircle node {$M$};
        \node[anchor=south] at (current bounding box.north) {$\overline{M}$};
    \end{tikzpicture}
\end{document}
1
  • 1
    Thank you so much for the answer @Vincent.
    – NilsK
    Commented Dec 8, 2020 at 21:07
4

One more solution ...

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}[
  node distance = 2mm and 8mm,
WEN/.style args = {#1/#2}{circle, draw=red!50, fill=#1!20, thick, minimum size=#2}
                        ]

\node (a) [WEN=red/24mm, 
           label={[xshift=8mm]left:$G$},
           label=$\overline{M}$]    {};
\node (b) [WEN=white/15mm, 
           right=of a.west]       {$M$};
    \end{tikzpicture}
\end{document}    

enter image description here

1
  • 1
    Thank you @Zarko.
    – NilsK
    Commented Dec 8, 2020 at 21:08
3

My code created with Mathcha (https://www.mathcha.io/editor) is more long but has the same output.

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\tikzset{every picture/.style={line width=0.75pt}} 
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
\draw  [color={rgb, 255:red, 246; green, 126; blue, 147 }  ,draw opacity=1 ][fill={rgb, 255:red, 252; green, 215; blue, 216 }  ,fill opacity=1 ][line width=1.5]  (189,150) .. controls (189,98.09) and (231.09,56) .. (283,56) .. controls (334.91,56) and (377,98.09) .. (377,150) .. controls (377,201.91) and (334.91,244) .. (283,244) .. controls (231.09,244) and (189,201.91) .. (189,150) -- cycle ;
\draw  [color={rgb, 255:red, 246; green, 126; blue, 147 }  ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 }  ,fill opacity=1 ][line width=1.5]  (258.5,150) .. controls (258.5,122.66) and (280.66,100.5) .. (308,100.5) .. controls (335.34,100.5) and (357.5,122.66) .. (357.5,150) .. controls (357.5,177.34) and (335.34,199.5) .. (308,199.5) .. controls (280.66,199.5) and (258.5,177.34) .. (258.5,150) -- cycle ;
\draw (232,135.4) node [anchor=north west][inner sep=0.75pt]  [font=\Large]  {$G$};
\draw (298,135.4) node [anchor=north west][inner sep=0.75pt]  [font=\Large]  {$M$};
\draw (273,25) node [anchor=north west][inner sep=0.75pt]  [font=\Large]  {$\overline{M}$};
\end{tikzpicture}

\end{document}

enter image description here

2
  • 1
    Thank you @Sebastiano.
    – NilsK
    Commented Dec 8, 2020 at 21:08
  • @NilsK My it was only a fast alternative :-). All the best.
    – Sebastiano
    Commented Dec 8, 2020 at 21:09

You must log in to answer this question.

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