TikZ-PGF Venn Diagrams – How to Draw Specific Venn Diagrams in LaTeX

tikz-pgfvenn-diagrams

I wish to draw the following Venn diagram as ilustrated below:
Ilustration

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.

\documentclass[tikz]{standalone}

\usetikzlibrary{backgrounds}

\begin{document}
    
    \begin{tikzpicture}
        
        \draw[save path = \circleX] (0,0) circle (1);
        \node[above] at (0,1) {$X$};
        \draw[save path = \circleY] (1,0) circle (1);
        \node[above] at (1,1) {$Y$};
        \draw[save path = \rectangleJ] (-0.4, -0.3) rectangle (1.5,0.5)
            node [below right] {$J$};
        \draw (-2,-2) rectangle (3,2)
            node [above] {$S$};
    
        \begin{scope}[on background layer]
            \clip[use path = \circleX];
            \clip[use path = \circleY];
            \clip[use path = \rectangleJ];
            
            \fill[use path = \rectangleJ, blue];
        \end{scope}
    
    \end{tikzpicture}

\end{document}

which results in:

enter image description here

EDIT

A way to get the J node at the bottom would be to do, instead of the \draw defining the rectangle:

\draw[save path = \rectangleJ] (-0.4, -0.3) coordinate (A)
                                    rectangle (1.5,0.5) coordinate (B);
\coordinate (C) at (A -| B);
\node[below] at (C) {$J$};

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.