I wish to draw the following Venn diagram as ilustrated below:
I already managed to do the following code, remains to draw the set $I = J \cap X \cap Y$ and to put the the letter J down, according to the Figure:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle (1) (0,1) node [text=black,above] {$X$}
(1,0) circle (1) (1,1) node [text=black,above] {$Y$}
(-0.4, -0.3) rectangle (1.5,0.5) node [text=black,above] {$J$}
(-2,-2) rectangle (3,2) node [text=black,above] {$S$};
\end{tikzpicture}
\end{document}
Best Answer
Here is a solution using the
save path
/use path
directives to avoid repeating code. I took the liberty of rewriting part of your code.The filled part is put on the background layer for it not to eat a part of the set borders.
which results in:
EDIT
A way to get the
J
node at the bottom would be to do, instead of the\draw
defining the rectangle:EDIT 2
To add the name of the filled area, a possibility is to add
node[pos = .5] {$I$}
at the end of the\draw
command defining the rectangle. Indeed, in this case, the intersection is more or less at the center of the rectangle.