3

I actually want to reproduce the following Venn diagram:

batman diagram

For this, it is important that the central overlapping zone is yellow; it would be nice to reproduce the other overlapping colors too...

This is my attempt, absolutely lame...

\documentclass[class=article,border=0pt]{standalone}
\usepackage{tikz}

\def\A{(0,0) circle (4cm)}
\def\B{(1,2) circle (4cm)}
\def\B{(2,0) circle (4cm)}


\begin{document}
    \begin{tikzpicture}
        \node[circle, fill=blue, opacity=.5, minimum size=4cm] (A) at (0,0) {};
        \node[circle, fill=red, opacity=.5, minimum size=4cm] (B) at (1,2) {};
        \node[circle, fill=green, opacity=.5, minimum size=4cm] (C) at (2,0) {};

\begin{scope}
\clip \A;
\fill[yellow] \B;
\end{scope}
    \end{tikzpicture}
\end{document}

I want to use it inside a Beamer presentation that I compile with LuaLaTeX

DaniCee
  • 2,217
  • What do you mean by customized colors? – Alenanno Jun 18 '15 at 09:39
  • This could help you http://www.texample.net/tikz/examples/venn-diagram-blended/ – Sigur Jun 18 '15 at 09:42
  • different to the ones you get just overlapping the circles... for example, I want yellow in the center, which is not the result of overlapping light blue, light green, and light red... or strong red (JERK), which is not the result of overlapping light blue and light green – DaniCee Jun 18 '15 at 09:42
  • Well, overlapping red and green you're not supposed to get blue navy. Unless you color the small sections yourself. – Alenanno Jun 18 '15 at 09:44
  • @Sigur, I tried it and with LuaLaTex I get the error "Package pgfkeys Error: I do not know the key '/tikz/blend group' and I am goi ng to ignore it" – DaniCee Jun 18 '15 at 09:46
  • @Aleanno, that's exactly my question, the Venn diagram is there in my example (if you remove the "scope" part), I just want specific colors for the overlapping regions. – DaniCee Jun 18 '15 at 09:46
  • @MaartenDhondt A better dupe would be How to color these circles in TikZ?, although it has been closed as a dupe itself to yours. :D But this question has nodes in each space too, so it could be considered not an exact duplicate. – Alenanno Jun 18 '15 at 11:17

3 Answers3

4

Here's a solution with pgfplots and intersections. There might be simpler solution (like with clipping), but this can be an alternative.

Credits: the Batman sign has been borrowed from this reddit thread.

Output

figure 1

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{intersections}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.12}
\tikzset{venn circle/.style={draw,circle,minimum width=3cm,draw=none,fill=#1!40,name path=#1}}

\newcommand{\batman}[1]{
    \begin{scope}[scale=.07, shift={(#1)}]
    \draw[fill,black]   (-0.25,1.48) .. controls (-0.1,1.5) and (0.1,1.5) .. (0.25,1.48) -- (0.35,1.92) .. controls (0.425,1.8) and (0.41,1.3) .. (0.45,1.2) .. controls (0.6,1.05) and (1.96,1.05) .. (1.98,2.08) -- (5.93,2.08) .. controls (4.2,1.45) and (4,0.3) .. (4.2,-0.28) .. controls (2.4,-0.09) and (0.4,-0.5) .. (0,-2.052) .. controls (-0.4,-0.5) and (-2.4,-0.09) .. (-4.2,-0.28) .. controls (-4,0.3) and (-4.2,1.45) .. (-5.93,2.08) -- (-1.98,2.08) .. controls (-1.96,1.05) and (-0.6,1.05) .. (-0.45,1.2) .. controls (-0.41,1.3) and (-0.425,1.8) .. (-0.35,1.92) -- (-0.25,1.48);
    \end{scope}
}

\begin{document}

\begin{tikzpicture}
\node[font=\Huge\scshape] at (90:3cm) {MEN};
    \node [venn circle=green,label={[label distance=-1.5cm]180:Smart}] (A) at (-150:1cm) {};
    \node [venn circle=blue,label={[label distance=-1.5cm]90:Handsome}] (B) at (90:1cm) {};
    \node [venn circle=red, label={[label distance=-1.5cm]0:Nice}] (C) at (-30:1cm) {};
\fill[red,
          intersection segments={
            of=green and blue,
            sequence={R2--L2}
          }]; 
\fill[blue!50!black,
          intersection segments={
            of=red and green,
            sequence={R1--L2--R0}
          }];
\fill[green!50!black,
          intersection segments={
            of=red and blue,
            sequence={R2--L2}
          }];
\path [
    name path=rag,
    intersection segments={
        of=green and red,
    }];
\fill[yellow,intersection segments={of=blue and rag,sequence=R2--B1}]  
    [intersection segments={of=rag and blue, sequence={--R2}}];               
    \node[font=\footnotesize,left,yshift=2mm] at (barycentric cs:A=1/2,B=1/2 ) {Jerk}; 
    \node[font=\footnotesize,below,yshift=-2mm] at (barycentric cs:A=1/2,C=1/2 ) {Nerd};  
    \node[font=\footnotesize,right,xshift=-1mm,yshift=2mm] at (barycentric cs:B=1/2,C=1/2 ) {Dumb}; 
    \batman{barycentric cs:A=1/3,B=1/3,C=1/3}
\end{tikzpicture}  
\end{document}
Alenanno
  • 37,338
3

Here is a suggestion using path picture as node option:

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
    kreis/.style={circle,fill=#1,minimum size=4cm},kreis/.default=none
  ]
  \def\tshift{.2cm}
  \path
    (0,0) coordinate (A)
    (1,2) coordinate (B)
    (2,0) coordinate (C)
  ;
  \path
    (A)
      node [kreis=green!20]{}
      node [below left=\tshift and \tshift] {SMART}
    (B)
      node [kreis=blue!20,
            path picture={\node[kreis=red!80!black!60] at (A){};}]{}
      node [above=\tshift] {HANDSOME}
    (C)
      node [kreis=red!20,
            path picture={
              \node[kreis=blue!50!red!80!black!70] at (A){};
              \node[kreis=green!80!black!60,
                    path picture={\node[kreis=yellow] at (A){};}
                    ] at (B){};}]{}
      node [below right=\tshift and \tshift]{NICE}
  ;
  \path
    (1,0) node [below=\tshift]{NERD}
    (1,1) node [above left=\tshift and 2.5*\tshift] {JERK}
          node [above right=\tshift and 2.5*\tshift]{DUMB}
          node [yshift=-\tshift,font=\Huge]{X}
  ;
    \end{tikzpicture}
\end{document}

enter image description here

esdd
  • 85,675
1

Here's a solution with clipping as in Draw ellipses with different coloring for their intersection in tikz?

\documentclass[tikz,border=2mm]{standalone}
\usepackage{xcolor}

\begin{document}
\begin{tikzpicture}[{every node/.style={black,font=\sffamily\Large}}]
    \def\firstcircle{(0,0) circle (3cm)}
    \def\secondcircle{(3,0) circle (3cm)}
    \def\thirdcircle{(1.5,3) circle (3cm)}
    \def\boundingbox{(-3,-3) rectangle (6,4.5)}

    \definecolor{handsome}{HTML}{C8CADF}
    \definecolor{jerk}{HTML}{EF3A43}
    \definecolor{batman}{HTML}{FBC405}
    \definecolor{dumb}{HTML}{B7CA54}
    \definecolor{smart}{HTML}{C7DAC4}
    \definecolor{nerd}{HTML}{4C4B6B}
    \definecolor{nice}{HTML}{E4B1AD}

    \node[font=\huge] at (1.5,6.5) {MEN};
    % fill circles
    \fill[smart] \firstcircle node[xshift=-1.5cm, yshift=-.5cm] {SMART};
    \fill[nice] \secondcircle node[xshift=1.5cm, yshift=-.5cm] {NICE};
    \fill[handsome] \thirdcircle node[yshift=1cm] {HANDSOME};

    % fill intersections
    % intersection of first and second
    \begin{scope}
        \clip \boundingbox \thirdcircle;
        \clip \firstcircle;
        \fill[nerd] \secondcircle node[black, xshift=-1.5cm, yshift=-.5cm] {NERD};
    \end{scope}
    % intersection of first and third
    \begin{scope}
        \clip \boundingbox \secondcircle;
        \clip \firstcircle;
        \fill[jerk] \thirdcircle node[xshift=-1.8cm, yshift=-1cm] {JERK};
    \end{scope}
    % intersection of second and third
    \begin{scope}
        \clip \boundingbox \firstcircle;
        \clip \secondcircle;
        \fill[dumb] \thirdcircle node[xshift=1.8cm, yshift=-1cm] {DUMB};
    \end{scope}
    % intersection of first, second and third
    \begin{scope}
        \clip \firstcircle;
        \clip \secondcircle;
        \clip \thirdcircle;
        \fill[batman] \boundingbox;
    \end{scope}

    \node at (1.5,1.2) {X};
\end{tikzpicture}
\end{document}

enter image description here