8

I want to make venn diagram using latex, here i already made :

\documentclass[tikz,border=10pt]{standalone} 
\usetikzlibrary{positioning,backgrounds}

\begin{document}

\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(60:2.1cm) circle (1.5cm)}
\def\thirdcircle{(0:2.1cm) circle (1.5cm)}

\begin{tikzpicture}

\draw \firstcircle node[below] {$1$};
\draw \secondcircle node [above] {$2$};
\draw \thirdcircle node [below] {$3$};

\node [text=black] at (30:20mm) {2};
\node [text=black, anchor=west, xshift=-2mm] at (90:10mm) {1};
\node (m) [text=black, below] at (0:10.5mm) {3};

\end{tikzpicture}
\end{document}

enter image description here

My Question : How to label in the intersection of first, second and the third circle (or otherwise at your discretion) ?

  • Welcome to tex.sx ! Just put nodes at the midway of pairs of centers, using a \path (a)--(b) node [midway] {text}; or using the calc tikzlibrary. (Sorry I can't answer I'm on atablet) – marsupilam Aug 7 '17 at 0:14
  • For the intersection of the three circles it is at the 2/3 [pos=.667] between (c) and that midway node (ab). – marsupilam Aug 7 '17 at 0:21
  • thank you for your comment but it still doesn't work, I got error – Roeny Aug 7 '17 at 0:31
  • This has been answered before. For example, check this . – Adarsh Aug 7 '17 at 0:47
5

Pick your style.

enter image description here enter image description here

\documentclass[12pt,tikz]{standalone}
\begin{document}
  \def\r{1}
  \def\R{1.3}
\begin{tikzpicture}[scale=1.5]
  \foreach\ang/\name in {-150/a,-30/b,90/c} \draw (\ang:\r) circle (\R) coordinate (\name) node {\name};
  \path (a) -- (b) node [midway] (ab) {ab} ;
  \path (b) -- (c) node [midway] (bc) {bc} ;
  \path (c) -- (a) node [midway] (ca) {ca} ;
  \path (c) -- (ab) node [pos=.667] (abc) {abc}; % actually (abc) is at (0,0) in this config !
\end{tikzpicture}
\begin{tikzpicture}[scale=1.5]
  \foreach\ang/\name in {-150/a,-30/b,90/c} \draw (\ang:\r) circle (\R) coordinate (\name) node {\name};
  \path (a) -- (b) coordinate [midway] (ab) ;
  \path (b) -- (c) coordinate [midway] (bc) ;
  \path (c) -- (a) coordinate [midway] (ca) ;
  \path (c) -- (ab) coordinate [pos=.667] (abc) node [pos=.667] {abc};
  \path (abc) -- (a) node [pos=-.75] {ab} ;
  \path (abc) -- (b) node [pos=-.75] {bc} ;
  \path (abc) -- (c) node [pos=-.75] {ca} ;
\end{tikzpicture}
\end{document}
| improve this answer | |
  • I want to use number to label the venn diagram but when i change the letter becomes number, it looks worse.... thanks – Roeny Aug 7 '17 at 1:34
  • I am a beginner in latex and I do not understand many things – Roeny Aug 7 '17 at 1:35
10

A code with the dedicated package:

    \documentclass[svgnames]{article}
    \usepackage{venndiagram}

    \begin{document}

    \begin{venndiagram3sets}[labelA= ,labelB= , labelC= ,radius=2cm, overlap=2cm]%
    \setkeys{venn}{shade=OliveDrab!40}
    \fillACapBCapC
    \setpostvennhook
    {%
    \draw (labelA) ++(-120:1.8cm) node{$ A$};
     \draw (labelB) ++(-60:1.8cm) node{$B$};
     \draw (labelC) ++(90:1.2cm) node{$C$};
    \draw (labelABC) ++(90:0.2cm) node{$A\cap B\cap C$}; 
    }%

    \end{venndiagram3sets}

    \end{document}

enter image description here

| improve this answer | |
5

When I was reading about probabilities long time ago, I've written these notes as a tool to simplify multi-events interactions via visualizing them. I hope you find them helpful.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{geometry}
\geometry{ a4paper,total={170mm,257mm},left=20mm,top=20mm}


\begin{document}
% Definition of circles
\def\firstcircle{ (0.0, 0.0) circle (1.5)}
\def\secondcircle{(2.0, 0.0) circle (1.5)}
\def\thirdcircle{ (1.0,-1.5) circle (1.5)}
\def\rectangle{ (-1.5,-3.0) rectangle (3.5,1.0) }
\colorlet{circle edge}{black}
\colorlet{circle area}{blue!30}

\tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
    outline/.style={draw=circle edge, thick}}

\setlength{\parskip}{5mm}
%############################################################################
%############################################################################
%############################################################################
\noindent
\begin{tikzpicture}
    \begin{scope}
        \clip  \firstcircle;
        \clip  \secondcircle;
        \fill[filled]   \thirdcircle ;
    \end{scope}
    \draw[outline] \firstcircle  node[left]  {$A$};
    \draw[outline] \secondcircle node[right] {$B$};
    \draw[outline] \thirdcircle  node[below] {$C$};
    \node[anchor=south] at (current bounding box.north) {$A \cap B \cap C$};
\end{tikzpicture} \qquad
%############################################################################
%############################################################################
%############################################################################
\begin{tikzpicture}
    \begin{scope}
        \clip \firstcircle \secondcircle \thirdcircle;
        \fill[filled]  \firstcircle \secondcircle \thirdcircle;
    \end{scope}
    \draw[outline] \firstcircle  node[left]  {$A$};
    \draw[outline] \secondcircle node[right] {$B$};
    \draw[outline] \thirdcircle  node[below] {$C$};
    \node[anchor=south] at (current bounding box.north) {$A \cup B \cup C$};
\end{tikzpicture} \qquad
%############################################################################
%############################################################################
%############################################################################
\begin{tikzpicture}
    \begin{scope}
        \clip \firstcircle;
        \fill[filled] \secondcircle;
    \end{scope}
    \draw[outline] \firstcircle  node[left]  {$A$};
    \draw[outline] \secondcircle node[right] {$B$};
    \draw[outline] \thirdcircle  node[below] {$C$};
    \node[anchor=south,align=center] at (current bounding box.north) 
      {$(A\cap B)=$\\$(A \cap B \cap C) + (A \cap B \cap C')$};
\end{tikzpicture} \\[1.5cm]
%############################################################################
%############################################################################
%############################################################################
\begin{tikzpicture}
    \begin{scope}
        \clip \firstcircle;
        \fill[filled] \thirdcircle;
    \end{scope}
    \begin{scope}
        \clip \firstcircle;
        \clip \secondcircle;
        \fill[white] \thirdcircle;
    \end{scope}
    \draw[outline] \firstcircle  node[left]  {$A$};
    \draw[outline] \secondcircle node[right] {$B$};
    \draw[outline] \thirdcircle  node[below] {$C$};
    \node[anchor=south] at (current bounding box.north) 
      {$(A\cap B' \cap C)$};
\end{tikzpicture} \qquad
%############################################################################
%############################################################################
%############################################################################
\begin{tikzpicture}
    \begin{scope}
        \fill[filled] \thirdcircle;
        \fill[white]  \firstcircle;
        \fill[white]  \secondcircle;
    \end{scope}
    \draw[outline] \firstcircle  node[left]  {$A$};
    \draw[outline] \secondcircle node[right] {$B$};
    \draw[outline] \thirdcircle  node[below] {$C$};
    \node[anchor=south] at (current bounding box.north) 
      {$(A' \cap B' \cap C)$};
\end{tikzpicture} \qquad
%############################################################################
%############################################################################
%############################################################################
\begin{tikzpicture}
     \begin{scope}
        \clip \secondcircle;
        \fill[filled] \thirdcircle;
    \end{scope}
    \fill[filled]  \firstcircle;
    \draw[outline] \firstcircle  node[left]  {$A$};
    \draw[outline] \secondcircle node[right] {$B$};
    \draw[outline] \thirdcircle  node[below] {$C$};
    \node[anchor=south] at (current bounding box.north) 
      {$A \cup (B \cap C)$};
\end{tikzpicture} \\[1.5cm]
%############################################################################
%############################################################################
%############################################################################
\begin{tikzpicture}
     \begin{scope}
        \clip \firstcircle \secondcircle;
        \fill[filled] \thirdcircle;
    \end{scope}
    \draw[outline] \firstcircle  node[left]  {$A$};
    \draw[outline] \secondcircle node[right] {$B$};
    \draw[outline] \thirdcircle  node[below] {$C$};
    \node[anchor=south] at (current bounding box.north) 
      {$(A \cup B) \cap C$};
\end{tikzpicture} \qquad

\end{document}
| improve this answer | |
3

There's a package for this!

enter image description here

\documentclass{article}
\usepackage{venndiagram}
\usepackage[margin=1in]{geometry}
\begin{document}
\begin{venndiagram3sets}[labelABC={\raisebox{10ex}{$A\cap B \cap C$}},tikzoptions={scale=3,thick}]
\end{venndiagram3sets}
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.