0

I'm looking to create a Venn diagram with 5 parts to it, with each part being inside the other, similar to:

enter image description here

However I'm not entirely sure where to begin. I've done a little reading on the tikz package and Venn diagrams in general but the best I can make uses this:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\foreach \X [count=\Y starting from 2] in {$\mathbb{N}$,$\mathbb{W}$,$\mathbb{Z}$,$\mathbb{Q}$,$\mathbb{R}$}
{\draw (-\Y,-\Y/2) circle ({1.5*\Y} and \Y);
\node at (1-2*\Y,-1.1*\Y) {\X}; }
\node[anchor=south]{};
\end{tikzpicture}

\end{document}

But this just does not give what I'm looking for. I'm currently getting an output like such:enter image description here

Any help to fix would be great!

5
  • Can you please add the missing lines, so the code compiles once copied? Also a screenshot of your current result would be helpful. Thank you
    – MS-SPO
    Jul 20 at 14:35
  • 1
    @MS-SPO Ah sorry just edited now! Should be able to compile now and I've included what my current diagram looks like... Jul 20 at 14:41
  • Welcome to TeX.SX! Would tex.stackexchange.com/q/678487/47927 ? (I currently can't find another answer of mine which would probably fit even better ...) Jul 20 at 14:42
  • @JasperHabicht Thank you! I'm trying to use this code but not sure how to change the diagram to have an anchor to the left, make the shapes oval and increase the gaps at the left edge Jul 20 at 14:50
  • 1
    Found it: tex.stackexchange.com/q/659704/47927 . This is, of course, pretty much what you currently get. Well, the code in both links are only meant as starting points. Jul 20 at 14:51

2 Answers 2

4

If you want to stick to the solution with the \foreach loop, you need to change the x and y coordinates in a way that you get the desired result, for example like this (added a vertical correction to the nodes, so that all letters sit on the same baseline):

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

\begin{document}
\begin{tikzpicture}
\foreach \X [count=\Y starting from 2] in
    {$\mathbb{N}$,$\mathbb{W}$,$\mathbb{Z}$,$\mathbb{Q}$,$\mathbb{R}$} {
        \draw ({0.5*\Y},0) circle ({0.75*\Y} and {0.25*\Y});
        \node[anchor=base, yshift=-0.67ex] at ({1.25*\Y-0.75},0) {\X}; 
    }
\end{tikzpicture}
\end{document}

enter image description here

4
  • 1
    Thank you very much! This was extremely useful Jul 20 at 15:01
  • Hi, what is W? :-) just a curiosity.
    – Sebastiano
    Jul 21 at 12:07
  • @Sebastiano I have not the slightest idea. It was in the OP's original code. Maybe it is the set of ... weird numbers? (ℕ means probably natural numbers without 0, and 𝕎 with zero ...) Jul 21 at 12:09
  • @JasperHabicht Thank you very much. I never have seen this notation.
    – Sebastiano
    Jul 23 at 21:15
3

Here's one way to do it. Perhaps you need to start working from inside out ...

  • help-grid starts at (0,0), extends 2 cm right and up \draw[help lines] (0,0) grid (2,2);
  • each path performs two actions \draw ( 0,0) ellipse (2cm and 1cm) node at (1.7,0) {R};
  • first, draw an ellipse with the given x- and y-radii
  • second put some text via a node (kindly watch the missing \)
  • move to the left, reducing radii, and shifting the text node, too

result

\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz}

\begin{document}
 \begin{tikzpicture}
    \draw[help lines] (0,0) grid (2,2);
    \draw (  0,0) ellipse (2cm and 1cm)     node at (1.7,0) {R};
    \draw (-.2,0) ellipse (1.7cm and .9cm)  node at (1.3,0) {Q};
    \draw (-.4,0) ellipse (1.4cm and .8cm)  node at (.7,0) {Z};
 \end{tikzpicture}
\end{document}

P.S.: Just for the fun of it, approaching supersonic ...

fun

\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz}
\usepackage{fontawesome}

\begin{document}
 \begin{tikzpicture}
    \draw[help lines] (0,0) grid (2,2);
    \draw (  0,0) ellipse (2cm and 1cm)     node at (1.7,0) {R};
    \draw (-.2,0) ellipse (1.7cm and .9cm)  node at (1.3,0) {Q};
    \draw (-.4,0) ellipse (1.4cm and .8cm)  node at (.7,0) {Z};
    \node[rotate=180] at (-1.6,0) {\faFighterJet};
 \end{tikzpicture}
\end{document}
3
  • 1
    Haha! Love the addition. This was quite easy to understand and helped a lot thank you! Made some adjustments to the ellipse sizes too :) Jul 20 at 15:02
  • Thank you :) Know your tools ...
    – MS-SPO
    Jul 20 at 15:03
  • 1
    @DuncanChrystal Actually, the original loop does pretty much the same, but it calculates the coordinates automatically and ... well, wrap everything in a loop. Of course, loops are sometimes hard to graps at first sight. But if you go through it step by step, you will discover that it is not too complicated actually. Jul 20 at 15:04

You must log in to answer this question.

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