Venn diagrams, relative so size of its content

Now I am looking if there is any easy way to create venn-diagrams where the circles/ellipses change size relative to its content. I am basically looking for simple compliments either on the form

or with three elements

The output I am looking for is somewhat along these lines

Where the size of the circles are relative to their percentages or probability. (Larger circles, larger probability) and the largest circle represents 1 or 100%

Now is it possible creating a macro that allows one to create such images? Example, given that A=40 , B=60 , A \cap B = 20

• In principle yes, but the math will be horrible Jul 9, 2012 at 21:32
• Horrible? You are speaking to a math undergrad ;) I am sure a solution can be aquired using the \calc package. Jul 9, 2012 at 21:45
• Horrible. Try solving for d in equation (14) in mathworld.wolfram.com/Circle-CircleIntersection.html Jul 9, 2012 at 22:10
• I did, gave me 4 solutions. However latex was not able to interpret the input, I probably did something wrong. Jul 9, 2012 at 22:11
• Recommend that you consider using rectangles instead of circles. Because there are many combination which cannot be displayed with circles. eg Sample space=100 A=60, B=40, A \cap B =20; cannot be done with circles. Additionally the computations with rectangles will be trivial. Jul 10, 2012 at 3:07

The answer is "impossible". You can't draw circles with the requested values : A=.40 , B=.60 , A \cap B = .20 like R. Schumacher wrote.

\documentclass[11pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{tikz,verbatim}
\usetikzlibrary{arrows,patterns}

\begin{document}

\begin{tikzpicture}[scale=4,>=latex']
\node[above right,magenta] at (0,1) {$\mathcal{C}$};
\draw (0.63245-1,0) circle [radius=0.63245cm];   % sqrt(0.4)
\draw (1-0.77459,0) circle [radius=0.77459cm];   % sqrt(0.6)
\node[above right] at (-1,0) {$\mathcal{C}_a$};
\node[above left] at ( 1,0) {$\mathcal{C}_b$};
\draw[->] (-1,0)--(1.2,0);
\draw[->] (0,-1)--(0,1.2);
\filldraw[blue] (0.63245-1,0) circle(.4pt) -- node[above right]{$ra\approx 0.632$}++(60:0.63245);
\filldraw[blue] (1-0.77459,0) circle(.4pt) -- node[above right]{$rb\approx 0.774$}++(60:0.77459);
\draw[magenta,<->] (0,0) -- node[below]{1} (1,0);
\clip (0.63245-1,0) circle [radius=0.63245cm];   % sqrt(0.4)
\clip (1-0.77459,0) circle [radius=0.77459cm];   % sqrt(0.6)
\draw[red,<->] (0.63245-1,-0.05) -- node[below]{0.59296} (1-0.77459,-0.05);

\node at (-0.25,-0.4){$\mathcal{A}$};
\end{tikzpicture}

\begin{verbatim}
Macro to determine the area of the asymmetric lens.
\pgfmathsetmacro{\ra}{sqrt(0.4)}
\pgfmathsetmacro{\rb}{sqrt(0.6)}
\pgfmathsetmacro{\d}{2-0.63245-0.77459}
\pgfmathsetmacro{\area}{%
(  \ra*\ra*acos((\d*\d-\rb*\rb+\ra*\ra)/(2*\d*\ra))/180*3.1415
+\rb*\rb*acos((\d*\d+\rb*\rb-\ra*\ra)/(2*\d*\rb))/180*3.1415
-0.5*sqrt((-\d+\ra+\rb)*(\d+\ra-\rb)*(\d-\ra+\rb)*(\d+\ra+\rb))
)/3.1415}
\end{verbatim}

\pgfmathsetmacro{\d}{2-0.63245-0.77459}
\pgfmathsetmacro{\ra}{sqrt(0.4)}
\pgfmathsetmacro{\rb}{sqrt(0.6)}
\pgfmathsetmacro{\area}{%
(  \ra*\ra*acos((\d*\d-\rb*\rb+\ra*\ra)/(2*\d*\ra))/180*3.1415
+\rb*\rb*acos((\d*\d+\rb*\rb-\ra*\ra)/(2*\d*\rb))/180*3.1415
-0.5*sqrt((-\d+\ra+\rb)*(\d+\ra-\rb)*(\d-\ra+\rb)*(\d+\ra+\rb))
)/3.1415}

The area of the circle $\mathcal{C}$  is $1\times \pi$.

The area of the circle $\mathcal{C}_a$  is $0.4\times \pi$.

The area of the circle $\mathcal{C}_b$  is $0.6\times \pi$.

If $d=0.59296$  then $\mathcal{A}=\area\times \pi$.

\pgfmathsetmacro{\d}{0.681}
\pgfmathsetmacro{\area}{%
(  \ra*\ra*acos((\d*\d-\rb*\rb+\ra*\ra)/(2*\d*\ra))/180*3.1415
+\rb*\rb*acos((\d*\d+\rb*\rb-\ra*\ra)/(2*\d*\rb))/180*3.1415
-0.5*sqrt((-\d+\ra+\rb)*(\d+\ra-\rb)*(\d-\ra+\rb)*(\d+\ra+\rb))
)/3.1415}

If $d=0.681$  then $\mathcal{A}=\area\times \pi$ but  $0.59296$  is the maximum value of $d$, so it's impossible to draw circles with the requested values.

\end{document}


For others values it's possible to use an iterative approach via nesting intervals (dichotomy) . I find 0.681 with a manual approach but I think it's not very difficult to build an algorithm to find this value.