How about this: I used hexagonal nodes instead of circles. You just need to set the colors and separation, the connections are automatically computed to be the average color of the nodes they connect. A node can be assigned one of two styles, venn
and unvenn
. While venn
draws the node, unvenn
makes it transparent. You don't need to remove the =some color
when using unvenn
, this parameter is simply not used in the definition of unvenn
.
The Code
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes}
\pgfdeclarelayer{background layer}
\pgfsetlayers{background layer,main}
\begin{document}
\colorlet{abccolor}{gray!50}
\colorlet{acolor}{red!50!gray}
\colorlet{abco\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes}
\pgfdeclarelayer{background layer}
\pgfsetlayers{background layer,main}
\begin{document}
\colorlet{abccolor}{gray!50}
\colorlet{acolor}{red!50!gray}
\colorlet{abcolor}{orange!50!gray}
\colorlet{bcolor}{yellow!50!gray}
\colorlet{bccolor}{green!50!gray}
\colorlet{ccolor}{blue!50!gray}
\colorlet{accolor}{violet!50!gray}
\pgfmathsetmacro{\nodescenterseparation}{4}
\begin{tikzpicture}
[ venn/.style={regular polygon, regular polygon sides=6,shape border rotate=30, minimum width=3cm,draw,inner sep=0,fill=#1,draw=#1!70!black,very thick},
unvenn/.style={regular polygon, regular polygon sides=6,shape border rotate=30, minimum width=3.5cm,opacity=0},
]
\node[venn=abccolor] at (0,0) (abc) {$A\cap B\cap C$};
\node[venn=acolor] at (0:\nodescenterseparation) (a) {$A$};
\node[venn=abcolor] at (60:\nodescenterseparation) (ab) {$A\cap B$};
\node[venn=bcolor] at (120:\nodescenterseparation) (b) {$B$};
\node[venn=bccolor] at (180:\nodescenterseparation) (bc) {$B\cap C$};
\node[venn=ccolor] at (240:\nodescenterseparation) (c) {$C$};
\node[venn=accolor] at (300:\nodescenterseparation) (ac) {$A\cap C$};
\begin{pgfonlayer}{background layer}
\fill[abccolor!50!acolor] (abc.corner 6) -- (abc.center) -- (abc.corner 5) -- (a.corner 3) -- (a.center) -- (a.corner 2) -- cycle;
\fill[abccolor!50!abcolor] (abc.corner 1) -- (abc.center) -- (abc.corner 6) -- (ab.corner 4) -- (ab.center) -- (ab.corner 3) -- cycle;
\fill[abccolor!50!bcolor] (abc.corner 2) -- (abc.center) -- (abc.corner 1) -- (b.corner 5) -- (b.center) -- (b.corner 4) -- cycle;
\fill[abccolor!50!bccolor] (abc.corner 3) -- (abc.center) -- (abc.corner 2) -- (bc.corner 6) -- (bc.center) -- (bc.corner 5) -- cycle;
\fill[abccolor!50!ccolor] (abc.corner 4) -- (abc.center) -- (abc.corner 3) -- (c.corner 1) -- (c.center) -- (c.corner 6) -- cycle;
\fill[abccolor!50!accolor] (abc.corner 5) -- (abc.center) -- (abc.corner 4) -- (ac.corner 2) -- (ac.center) -- (ac.corner 1) -- cycle;
\fill[acolor!50!abcolor] (a.corner 2) -- (a.center) -- (a.corner 1) -- (ab.corner 5) -- (ab.center) -- (ab.corner 4) -- cycle;
\fill[abcolor!50!bcolor] (ab.corner 3) -- (ab.center) -- (ab.corner 2) -- (b.corner 6) -- (b.center) -- (b.corner 5) -- cycle;
\fill[bcolor!50!bccolor] (b.corner 4) -- (b.center) -- (b.corner 3) -- (bc.corner 1) -- (bc.center) -- (bc.corner 6) -- cycle;
\fill[bccolor!50!ccolor] (bc.corner 5) -- (bc.center) -- (bc.corner 4) -- (c.corner 2) -- (c.center) -- (c.corner 1) -- cycle;
\fill[ccolor!50!accolor] (c.corner 6) -- (c.center) -- (c.corner 5) -- (ac.corner 3) -- (ac.center) -- (ac.corner 2) -- cycle;
\fill[accolor!50!acolor] (ac.corner 1) -- (ac.center) -- (ac.corner 6) -- (a.corner 4) -- (a.center) -- (a.corner 3) -- cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
Result with all sets non-empty
Result with ABC, A and BC empty
\node[unvenn=abccolor] at (0,0) (abc) {$A\cap B\cap C$};
\node[unvenn=acolor] at (0:\nodescenterseparation) (a) {$A$};
\node[venn=abcolor] at (60:\nodescenterseparation) (ab) {$A\cap B$};
\node[venn=bcolor] at (120:\nodescenterseparation) (b) {$B$};
\node[venn=bccolor] at (180:\nodescenterseparation) (bc) {$B\cap C$};
\node[unvenn=ccolor] at (240:\nodescenterseparation) (c) {$C$};
\node[venn=accolor] at (300:\nodescenterseparation) (ac) {$A\cap C$};
Right, here's some code:
\documentclass{standalone}
%\url{https://tex.stackexchange.com/q/67395/86}
\usepackage{tikz}
\makeatletter
\def\venn@strip#1#2\venn@STOP{%
\def\venn@next{#1}%
\gdef\venn@rest{#2}%
}
\newcommand{\venn}[1]{%
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (2,0);
\coordinate (C) at (1,{sqrt(3)});
\coordinate (S-SE) at (5,-3);
\coordinate (S-NW) at (-3,{sqrt(3)+3});
\edef\venn@rest{#100000000}%
\foreach \i in {0,...,7} {
\begin{scope}[even odd rule]
\expandafter\venn@strip\venn@rest\venn@STOP
\ifnum\venn@next=1\relax
\pgfmathparse{Mod(\i,2) == 1 ? "(S-SE) rectangle (S-NW)" : ""}
\path[clip] \pgfmathresult (A) circle[radius=2];
\pgfmathparse{Mod(floor(\i/2),2) == 1 ? "(S-SE) rectangle (S-NW)" : ""}
\path[clip] \pgfmathresult (B) circle[radius=2];
\pgfmathparse{Mod(floor(\i/4),2) == 1 ? "(S-SE) rectangle (S-NW)" : ""}
\path[clip] \pgfmathresult (C) circle[radius=2];
\fill[rounded corners,red] (S-SE) rectangle (S-NW);
\fi
\end{scope}
}
\draw[ultra thick] (A) circle[radius=2];
\draw[ultra thick] (B) circle[radius=2];
\draw[ultra thick] (C) circle[radius=2];
\draw[ultra thick,rounded corners] (S-SE) rectangle (S-NW);
\end{tikzpicture}
}
\makeatother
\newcommand{\allvendiagrams}{
% To generate the lot:
\foreach \j in {0,...,255} {
\def\venncode{}
\foreach \k in {0,...,7} {
\pgfmathparse{Mod(floor(\j/2^\k),2) == 1 ? "\venncode1" : "\venncode0"}
\global\let\venncode=\pgfmathresult
}
\venn{\venncode}
}
}
\begin{document}
\venn{10000000}
\venn{01000000}
\venn{11000000}
\end{document}
And here's the result:
I almost certainly have used a different code for the different regions - I went for simpler code. The rubric is that a 1
in the kth place fills the kth region, and the correspondence between labels and regions is to write out k as a binary number, then if the bit is set, that circle is used inside and if not, outside. At the end, we draw the region and circles on top. I haven't gone for much customisability, but hopefully it's fairly obvious what to change to get it to look different.
Edit from the questioner:
By using \documentclass[border=3pt,tikz]{standalone}
and invoking \allvendiagrams
instead of \venn{10000000}\venn{01000000}\venn{11000000}
, the output will show all the Venn diagrams as follows. But not in GIF for sure.
Best Answer
A simple solution is