2

I would like to draw a stacked venn diagram in latex that looks like the following figure.enter image description here

Please any help. Thank you in advance.

Edited: I have tried to modify this latex, but got stock:

    \usetikzlibrary{arrows.meta} 
\usetikzlibrary{decorations.text}

\begin{tikzpicture}[scale=0.85] 
\foreach \X [count=\Y starting from 2] in 
{A,B,C} 
{\draw (-\Y,-\Y/2) circle ({1.5*\Y} and \Y);
\path[decoration={text along path,
text={classes |\itshape|\X},text align=center,raise=0.2em},decorate] (-\Y,-\Y/2) +(-1.5*\Y,0) arc(180:360:{1.5*\Y} and \Y);
} 
\draw ([xshift=-0.5cm,yshift=-0.5cm]current bounding box.south west) 
rectangle ([xshift=0.5cm,yshift=0.5cm]current bounding box.north east); 
\node[anchor=south] at (current bounding box.north) {\textbf{Three classes}}; 
\end{tikzpicture}
2
  • Welcome to TeX.SX! What did you try so far? A quick Google search should at least get you some possible basic ways to do this. Please tell us where exactly you got stuck with. Also, do you wish to draw more like these diagrams? Should parts be shaded? Mar 6 at 18:23
  • 1
    There are a couple of packages on CTAN that can help you create Venn diagrams with LaTeX. One of them is the venndiagram package which assists in generating simple two- and three-set Venn diagrams. Another package is simply called venn. Have a look
    – scd
    Mar 6 at 18:30

1 Answer 1

5

A very simple solution using a \foreach loop based on the code you provided could be:

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

\begin{document}

\begin{tikzpicture}[scale=0.5]
\foreach \x [count=\y] in {A,B,C} {
    \draw (0,{-\y}) circle[radius=\y];
    \node at (0,{-2*\y+1}) {\x};
} 
\end{tikzpicture}

\end{document}

enter image description here

But note that you might want to draw the three circles beginning from the largest to the smallest if you want to fill them with some color for example, otherwise the largest circle would cover the others:

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

\begin{document}

\begin{tikzpicture}[scale=0.5]
\foreach \x/\z [count=\y] in {C/yellow,B/orange,A/red} {
    \draw[fill=\z] (0,{\y-4}) circle[radius={4-\y}];
    \node at (0,{-2*(4-\y)+1}) {\x};
} 
\end{tikzpicture}

\end{document}

enter image description here

0

You must log in to answer this question.

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