There is a package that specializes on Venn diagrams: venndiagram
. One needs to "hack" it a bit since the intersection you are after seems not be in the predefined set, but this is what \setpostvennhook
is for. This hack defines the interiors and the contours of the circles. They have the names A, B and C, but their labels can be set to X, Y and Z, say.
\documentclass[border=10pt]{standalone}
\usepackage{venndiagram}
\makeatletter% https://tex.stackexchange.com/a/499947
\tikzset{interior/.style={insert path={
(\csname @venn@#1x\endcsname,\csname @venn@#1y\endcsname) circle[radius=\@venn@radius-\pgflinewidth/2]}},
contour/.style={insert path={
(\csname @venn@#1x\endcsname,\csname @venn@#1y\endcsname) circle[radius=\@venn@radius]}}}
\makeatother
\begin{document}
\begin{venndiagram3sets}[labelA=$X$,labelB=$Y$,labelC=$Z$]
\fillA
\setpostvennhook{
\clip[interior=B];
\fill[white,interior=C];
\draw[contour=A];}
\end{venndiagram3sets}
\end{document}

ADDENDUM: Since this is a repeating theme, I am trying to collect some standard tricks here, and also add some stuff to the venndiagram
repertoire.
- The
reverse clip
trick allows one to clip on everything outside a given path.
- The
even odd clip
trick allows one to apply the even odd rule
to clips.
- I added the styles
interior of
, which produce a path that contains the interior of either A, B, or C, contour of
which allows one to redraw the contour of either A, B, or C, and common of
, which allows one to retrieve the intersection of two of the sets. The latter requires the calc
library.
Using these tricks, one can avoid overpainting anything in white. We first clip on everything outside the intersection of B and C,
\clip[common of=B and C,reverse clip];
and then fill the interior of A,
\fill[\VennShade,interior of=A];
Complete MWE. (Notice that some care is taken not to add any hard coded distances, the idea being that you produce several diagrams and have common settings.)
\documentclass[border=10pt]{standalone}
\usepackage{venndiagram}
\usetikzlibrary{calc,backgrounds}
\makeatletter% https://tex.stackexchange.com/a/499947
\tikzset{interior of/.style={insert path={
(\csname @venn@#1x\endcsname,\csname @venn@#1y\endcsname) circle[radius=\@venn@radius-\pgflinewidth/2]}},
contour of/.style={insert path={
(\csname @venn@#1x\endcsname,\csname @venn@#1y\endcsname)
circle[radius=\@venn@radius]}},
midpoint of/.style={insert path={
(\csname @venn@#1x\endcsname,\csname @venn@#1y\endcsname)
}},
common of/.style args={#1 and #2}{insert path={
let \p1=($(\csname @venn@#2x\endcsname,\csname @venn@#2y\endcsname)-(\csname @venn@#1x\endcsname,\csname @venn@#1y\endcsname)$),
\n1={veclen(\y1,\x1)/2},\n2={sqrt(\@venn@radius*\@venn@radius-\n1*\n1)},
\n3={atan2(\y1,\x1)},\n4={atan2(\n2,\n1)} in
($(\csname @venn@#1x\endcsname,\csname @venn@#1y\endcsname)+(\n3+\n4:\@venn@radius)$)
arc(\n3+\n4:\n3-\n4:\@venn@radius) arc(\n3+180+\n4:\n3+180-\n4:\@venn@radius)
-- cycle
%\pgfextra{\typeout{\n2,\n3,\n4,\@venn@radius}}
}},
reverse clip/.style={insert path={{% https://tex.stackexchange.com/a/127045
[overlay] (0,0) -|
(\@venn@w,\@venn@h) -| cycle
}}},
even odd clip/.code={% https://tex.stackexchange.com/a/76216
\pgfseteorule}}
\def\VennShade{\@venn@shade}
\makeatother
\begin{document}
\begin{venndiagram3sets}[labelA=$X$,labelB=$Y$,labelC=$Z$]
\setpostvennhook{
\begin{scope}[on background layer]
\clip[common of=B and C,reverse clip];
\fill[\VennShade,interior of=A];
\end{scope}}
\end{venndiagram3sets}
\end{document}
