Example: Venn diagram with magnifier

Published 2010-01-30 | Author: Dennis Heidsiek

This example shows how to add a glass to magnify a special part of a pictures. It makes use of the new spy library, so you’ll need a recent TikZ version [1] to compile it.

It was created by Dennis Heidsiek [2], based on the example [3], inspired by a sketch in [4].

Download as: [PDF] [TEX]

Venn diagram with magnifier

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Venn diagram with magnifier
% Author: Dennis Heidsiek



% First, we define three circles:
\def\firstcircle{(-2,0) circle (2.4)}
\def\secondcircle{(2,0) circle (2.4)}
\pgfmathparse{-(2.4^2-2^2)^0.5} % by pythagoras
\let\h\pgfmathresult % shortcut for further use
\def\thirdcircle{(0,\h) circle (0.2cm)}

 % Let's draw the scene (to magnify):
  \begin{scope}[spy using outlines=
      {magnification=16, size=8cm, connect spies, rounded corners}]
    % the boarder:
    \draw[thick, rounded corners] (-5,-4) rectangle (5,4);
    \draw (0,3.3) node[scale=2] {the universe of all jobs};
    % The transparency:
    \begin{scope}[fill opacity=0.5]
      \fill[red] \firstcircle;
      \fill[green] \secondcircle;
      \fill[blue] \thirdcircle;
    % letterings and missing pieces:
    \draw[align=center] \firstcircle node {what you\\would like\\to do};
    \draw[align=center] \secondcircle node {what you\\are able\\to do};
    \draw \thirdcircle
      (0,-2.3) node[align=center] {em-\\ployment\\you get paid enough for};
    \fill (0,\h+0.12) circle (0.005)
        node[scale=0.11, align=center] {perfect\\job};
    % now we can draw the magnifying glass:
    \spy [red] on (0,\h) in node [left] at (13.25,0);



  • #1 Jakob, February 2, 2010 at 7:37 p.m.

    This is a very stupid example based on primitive sexism. It gives the impression that TikZ is particularly for male nerds which judge a woman depending on whether she would sleep with them. Why including this example if you can also show the power of TikZ without sexism? How about replacing the green set with "what you would like to do", the red set with "what you are able to do", the blue with "jobs you get paid enough for" and the marker with "the perfect job"?

  • #2 Frakturfreund, February 3, 2010 at 2:32 a.m.

    Hello Jakob, thank you for your feedback! I personally think that this may be a little bit overacted case of political correctness (since this was really clearly humor), but your objection is comprehensible, so your proposed changes will be uploaded soon. Besides, the superior number of male contributers in this gallery is actually a sad fact, but i highly doubt that the small corrections on this example will change this in any way. :(

    PS: Viele Grüße von einem Muttersprachler an den anderen :).

  • #3 Kjell Magne Fauske, February 3, 2010 at 8:53 p.m.

    I have now uploaded the new version of the example.

  • #4 Jakob, February 8, 2010 at 12:55 p.m.

    Danke für die Änderung! :-)

  • #5 flying sheep, February 14, 2010 at 5:35 p.m.

    Zusätzlich ist die Zahl deutscher Nutzer von TeX, LaTeX und TikZ ungleich höher als die jeder anderen Muttersprache (trotzdem reden alle englisch)

  • #6 Ricardo, April 22, 2010 at 2:43 p.m.

    I use Miktex 2.8 and found this problem. Does anybody knows how to fix it ?

    ("C:\Program Files (x86)\MiKTeX 2.8\tex\generic\pgf\frontendlayer\tikz\librarie s\tikzlibrarytopaths.code.tex" File: tikzlibrarytopaths.code.tex 2008/01/09 v2.00 (rcs-revision 1.1) ))) ! I can't find file tikzlibraryspy.code.tex'. <argument> ...nput tikzlibrary\pgf@temp .code.tex \catcode\@ =\csname tikz... l.6 \usetikzlibrary{spy}

    Please type another input file name ! Emergency stop. ...nput tikzlibrary\pgf@temp .code.tex \catcode `\@ =\csname tikz... l.6 \usetikzlibrary{spy}

    *** (job aborted, file error in nonstop mode)

    Thanks in advance,


  • #7 Rafael, May 13, 2010 at 11 a.m.

    I have the recent version (18.04.2010) of tikz, but the code cannot be compiled without mistakes. In the example of differcial-quotient its the same. Is the spy-library the problem?

  • #8 Frakturfreund, June 3, 2010 at 10:20 p.m.

    It compiles with the 2010-06-02 build of TikZ, but the correct output is only produced with pdflatex—using xelatex, the spy transformmation is incorrect and results in a defect pdf. So there’s still a bug … :(

  • #9 Brett Lee, May 31, 2012 at 10:12 p.m.

    Thank you for sharing this information this post is very useful. hamilton airport limo

  • #10 Brett Lee, May 31, 2012 at 10:12 p.m.

    Thank you for sharing this information this post is very useful. hamilton airport limo

Adding comments is currently not enabled.