2

I can generate the following but need to modify it to include shading of the intersection of circle A and B - C. Any suggestions?

\documentclass[border=0.2cm]{standalone}
% Required packages
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}

\begin{document} \begin{tikzpicture}[thick, set/.style = {circle, minimum size = 3cm, fill=black!30}] % Set A \node[set,label={135:$A$}] (A) at (0,0) {};

% Set B \node[set,fill=white, label={45:$B$}] (B) at (1.8,0) {};

% Set C \node[set,label=$C$] (C) at (0.9,1.5) {};

% Intersection \begin{scope}

\clip (0,0) circle(1.5cm); \clip (1.8,0) circle(1.5cm); \clip (0.9,1.5) circle(1.5cm); \fillwhite!60 circle(1.5cm);

\end{scope}

% Circles outline \draw (0,0) circle(1.5cm); \draw (1.8,0) circle(1.5cm); \draw (0.9,1.5) circle(1.5cm);

\end{tikzpicture}

\end{document}

enter image description here

Sebastiano
  • 54,118

2 Answers2

2

One way to filling of the intersection of circle A and B-C is first filling the whole figure, then filling its complement. The following code is from here, and adding a filling with even odd rule

\fill[gray!20,draw,even odd rule] \cirA \cirB;

enter image description here

The code

\documentclass[tikz,border=0.2cm]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
\def\r{1.5} % radius of two circles
\def\d{1}   % distance of two centers
\def\cirA{(210:\d) circle(\r)}
\def\cirB{(-30:\d) circle(\r)}

\draw[fill=yellow] \cirA +(135:\r+.3) node{$A$} \cirB +(45:\r+.3) node{$B$};

% Fill the complement of intersection of A and B-C \begin{scope} \clip \cirA; \clip \cirB; \draw[fill=gray!20] (90:\d) circle(\r); \end{scope}

\fill[gray!20,draw,even odd rule] \cirA \cirB;

% Circles outline \draw \cirA \cirB; \end{tikzpicture} \end{document}

Black Mild
  • 17,569
2

My suggestion it is humble. There is a very nice package venndiagram of Nicola L. C. Talbot. It is very simple. Check if the diagram is correct.

\documentclass{standalone}
\usepackage{venndiagram}
\begin{document}
\begin{venndiagram3sets}
\fillACapBNotC
\end{venndiagram3sets}
\end{document}

enter image description here

or this.....

\documentclass{standalone}
\usepackage{venndiagram}
\begin{document}
\begin{venndiagram3sets}
\fillACapBCapC
\end{venndiagram3sets}
\end{document}

enter image description here

Sebastiano
  • 54,118