2

This question already has an answer here:

How can I color the output of this MWE like the screenshot?

\documentclass{book}
\usepackage{tikz} 
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw [thick] (3.25,-2) circle (1.5cm)      node[right=.7cm, above=.4cm] {$A$};
\draw [thick] (2.5,-3.5) circle (1.5cm)     node[left=.7cm,] {$B$};
\draw [thick] (4,-3.5) circle (1.5cm)       node[right=.7cm] {$C$};
\draw [thick](0,0) rectangle (6.5,-5.5)     node[left=6cm, above=.3cm] {$M$};
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

marked as duplicate by Andrew Swann, Gonzalo Medina tikz-pgf Feb 22 '15 at 18:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

Easiest is to fill the circles first and then draw them.

\documentclass{book}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\fill[gray!50] (3.25,-2) circle (1.5cm);
\fill[gray!50] (2.5,-3.5) circle (1.5cm);
\fill[white] (4,-3.5) circle (1.5cm);
\draw [thick] (3.25,-2) circle (1.5cm)      node[right=.7cm, above=.4cm] {$A$};
\draw [thick] (2.5,-3.5) circle (1.5cm)     node[left=.7cm,] {$B$};
\draw [thick] (4,-3.5) circle (1.5cm)       node[right=.7cm] {$C$};
\draw [thick](0,0) rectangle (6.5,-5.5)     node[left=6cm, above=.3cm] {$M$};
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

You can colour each region by suitably clipping:

\documentclass{book}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\fill[gray!50] (3.25,-2) circle (1.5cm);
\fill[gray!50] (2.5,-3.5) circle (1.5cm);
\fill[yellow] (4,-3.5) circle (1.5cm);
\begin{scope}
  \clip (2.5,-3.5) circle (1.5cm);
  \fill[blue!50] (3.25,-2) circle (1.5cm);
\end{scope}
\begin{scope}
  \clip (3.25,-2) circle (1.5cm);
  \fill[red!50] (4,-3.5) circle (1.5cm);
\end{scope}
\begin{scope}
  \clip (2.5,-3.5) circle (1.5cm);
  \fill[olive!50] (4,-3.5) circle (1.5cm);
\end{scope}
\begin{scope}
  \clip (2.5,-3.5) circle (1.5cm);
  \clip (3.25,-2) circle (1.5cm);
  \fill[green!50] (4,-3.5) circle (1.5cm);
\end{scope}
\draw [thick] (3.25,-2) circle (1.5cm)      node[right=.7cm, above=.4cm] {$A$};
\draw [thick] (2.5,-3.5) circle (1.5cm)     node[left=.7cm,] {$B$};
\draw [thick] (4,-3.5) circle (1.5cm)       node[right=.7cm] {$C$};
\draw [thick](0,0) rectangle (6.5,-5.5)     node[left=6cm, above=.3cm] {$M$};
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

  • Thanks for your fast reply but I want to learn the general solution. For example your solution doesn't work if we want to color the region between A\cap B (I'm working on Venn diagrams). Could you please help me to color this region? – Sisabe Feb 22 '15 at 13:45
  • @Sisabe Please see the edit. – user11232 Feb 22 '15 at 14:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.