5

Further to my question on Venn diagrams overlapping color filling, I have the following MWE:

\documentclass{book}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,fadings,patterns}
\begin{document}
\begin{figure}[h]\centering
\pagestyle{empty}
\def\firstcircle{(0,0) circle (2.0cm)}
\def\secondcircle{(360:3.5cm) circle (2.0cm)}
\begin{tikzpicture}
\begin{scope}
    \fill[style=shade, top color=white, bottom color=brown!80!black!20][black] \firstcircle;
    \fill[style=shade, top color=white, bottom color=cyan!80!black!20 ][black] \secondcircle;
    \draw \firstcircle node{\textsc{Rules-Based (Passive)}};
    \draw \secondcircle node{\textsc{Bet Against Market Portfolio (Active)}};
     \clip \firstcircle;
  \fill[red][fill opacity=0.6]\secondcircle;
\end{scope}
\end{tikzpicture}
\end{figure}
\end{document}

However, instead of output (bottom picture) I want to achieve a Venn-diagram that includes circles and can handle longer text; similar to this (upper picture in blue and purple): How to achieve this?Double Venn

  • 1
    Use align=center for the nodes and `\` to mark the desired line-breaks? – cfr Oct 23 '14 at 12:19
  • Adding the ['align=center'] did not alter the figure. Maybe I misplaced the command?: \secondcircle; \draw \firstcircle node[align=center]{\textsc{Rules-Based/ (Passive)}}; \draw \secondcircle node[align=center]{\textsc{Bet Against/ Market Portfolio/ (Active)}}; – Lingskiwitz Oct 23 '14 at 12:38
  • NB reversing the / in \ did not alter either – Lingskiwitz Oct 23 '14 at 12:45
  • Should be `\\` but the system turned my double backslash into a single. Sorry about that. – cfr Oct 23 '14 at 13:20
  • 3
    A minor pedantic point — the figure 1.2 above is an Euler diagram, not a Venn diagram. – Aaron Oct 23 '14 at 17:20
12

A possible implementation with the new Blend Modes feature from TikZ v. 3.0.0 (see What are the new features in TikZ/pgf 3.0?). This allows to avoid using some clip operation:

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

\begin{document}
\def\firstcircle{(0,0) circle (3.0cm)}
\def\secondcircle{(360:3.5cm) circle (3.0cm)}
\begin{tikzpicture}[blend group=screen]
\begin{scope}[fill opacity=0.3,text opacity=1,white,align=center,text width=2.5cm]
    \draw[fill=blue!50!cyan!60!black] \firstcircle 
    node[shift={(-.75,1)},text=blue!50!cyan!60!black]{\textsc{Rules-Based (Passive)}};
    \draw[fill=violet!60!red] \secondcircle 
    node[shift={(.75,1)},text=violet!60!red]{\textsc{Bet Against Market Portfolio (Active)}};
    \node[text=white] at (1.65,0){\textsc{Strategic Beta}};
    \begin{scope}[scale=0.8,transform shape,align=center,white,fill opacity=1]% little circles
    \draw[fill=blue!50!cyan!60!black](-0.5,-1.25)circle(1.45cm) 
     node[text width=2.25cm,text=white] {\textsc{Market-Cap\\ Weighted}};

     \draw[fill=violet!60!red](6,-1.25)circle(1.35cm) 
     node[text width=2.25cm,text=white] {\textsc{Actively\\ Managed}};
    \end{scope}
\end{scope}
\end{tikzpicture}

\end{document}

The result:

enter image description here

  • 1
    Well done Claudio! In my document class [github.com/suchow/Dissertate], in which I have added the tikz package and its relevant commands, I have no output, though. Trust your code is right (given your shown output) and I will try to manage to get the PDF output! – Lingskiwitz Oct 23 '14 at 13:02
  • @Lingskiwitz: Glad you like it! The point, as said at the beginning, is that blend group=screen only works with the newest TikZ version. You can check yours by inserting somewhere in the document \pgfversion. – Claudio Fiandrino Oct 23 '14 at 13:04
  • I use Tikz 3.0; the error-log gives: Tex capacity exceeded, sorry [input stack size=5000]. (...t={(-.75,1)},text=blue!50!cyan!60!black]{...) – Lingskiwitz Oct 23 '14 at 14:06
  • @Lingskiwitz: Why don't you compile the current document and you include the resultant pdf via \includegraphics? Unfortunately, by only seeing the error it is really not possible to give you a correct feedback. – Claudio Fiandrino Oct 23 '14 at 14:20
  • That is a good suggestion. I also see some alternative solutions on expanding Tikz memory at http://tex.stackexchange.com/questions/7953/how-to-expand-texs-main-memory-size-pgfplots-memory-overload; though it appears they come with backlashes. Thanks again Claudio! – Lingskiwitz Oct 23 '14 at 14:26
5

You can also do this sort of diagram in plain Metapost, using the built in colour-arithmetic.

enter image description here Colours can be thought of as (r,g,b) 3-tuples, but you can add, subtract, and scale them as vectors. Plain MP defines

  • red as (1,0,0)
  • green as (0,1,0)
  • blue as (0,0,1)
  • and white as (1,1,1).

Values >1 are treated as 1 for the purposes of making colours. Adding up two colours and subtracting enough white to get each component back into the range 0 to 1, usually makes a nice blend of them.

prologues := 3;
outputtemplate := "%j%c.eps";
verbatimtex
\let\\=\cr
\font\sc=phvr8r
\def\stack#1{$\vcenter{\halign{\sc{##}\hfil\cr#1\crcr}}$}
etex
beginfig(1);

u = 8mm;

path a[];
a1 = fullcircle scaled 9u shifted (3u,0);
a2 = fullcircle scaled 9u shifted (-3u,0);
a3 = fullcircle scaled 3u shifted (4u,-2u);
a4 = fullcircle scaled 3u shifted (-2u,-2u);
a5 = buildcycle(subpath(-2,2) of a2, a1);
a6 = buildcycle(subpath(-2,2) of a4, a1);

color filler[];
filler1 = .2 red  + .1 blue  + .7 white; 
filler2 = .2 blue + .1 green + .7 white;
filler3 = .6 red + .3 blue;
filler4 = .55 blue + .35 green;
filler5 = filler1+filler2-white;
filler6 = filler1+filler4-white;

for i=1 upto 6: fill a[i] withcolor filler[i]; endfor
for i=1 upto 4: draw a[i] withpen pencircle scaled 0.2 withcolor white; endfor

label(btex \stack{Bet Against\\
              Market Portfolio\\(Active)} etex scaled 1.4, center a1 shifted (+2/3u,2u)) withcolor .5 red + .05 blue;
label(btex \stack{Rules-Based\\(Passive)} etex scaled 1.4, center a2 shifted (-2/3u,2u)) withcolor .1 green + .35 blue + .1 white;
label(btex \stack{Actively\\Managed}      etex, center a3) withcolor white;
label(btex \stack{Market-Cap\\Weighted}   etex, center a4) withcolor white;
label(btex \stack{Strategic\\Beta}        etex, center a5) withcolor white;  

endfig;
end.
  • This seems a solution for those familiar with Metapost. On a personal note, this is getting too complicated for me to implement. – Lingskiwitz Oct 23 '14 at 16:37
1

This might consist of a hint:

\begin{tikzpicture}[every node/.style={font=\small}]
\begin{scope}
  \node[draw,circle,minimum width=3cm,fill,style=shade, top color=white, bottom color=brown!80!black!20] (one) at (0,0) {};
  \node[below,align=left, text width=1.5cm] at ($(one.north)+(0,-.5)$) {This is a random text};
  \node[draw,circle,minimum width=3cm,fill,style=shade, top color=white, bottom color=green!80!black!20] (two) at (2,0) {};
  \node[below,align=left, text width=1.5cm] at ($(two.north)+(.5,-.5)$) {This is a random text};
  \clip (0,0) circle (1.5cm);
  \fill[red,fill opacity=0.6] (2,0) circle (1.5cm);
\end{scope}
\end{tikzpicture}

You'll need calc tikzlibrary in addition to your shapes,fadings,patterns.

  • This is a hint, but how to insert the two circles inside circles; and how to get the texts inside? (see my template/ desired output). – Lingskiwitz Oct 23 '14 at 12:50

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.