## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Venn Diagrams and Intersection Points

Information and discussion about graphics, figures & tables in LaTeX documents.
asmithb
Posts: 4
Joined: Tue Feb 23, 2021 12:04 pm

### Venn Diagrams and Intersection Points

Dear Community,

I want to graph some Venn diagrams and highlight some intersection points, as shown on this website: https://verfassungsblog.de/veto-players ... -part-1-2/

I have added the picture of the website I am interested in. I want to highlight point SQ and the point where A and B intersect. However, I only find codes to highlight the intersection areas (but not the points themselves) and to magnify the intersection points (though I am not interested in magnifying such points).

Thank you very much for your support
Attachments
VPs.png (118.38 KiB) Viewed 205 times

Bartman
Posts: 160
Joined: Fri Jan 03, 2020 2:39 pm
If you use tikz for the drawing, the intersection points can be calculated. You can use the assigned names or choose them yourself.

asmithb
Posts: 4
Joined: Tue Feb 23, 2021 12:04 pm

[\documentclass{article}

\usepackage{tikz}

\RequirePackage{xkeyval}
\RequirePackage{tikz}
\RequirePackage{etoolbox}

\usetikzlibrary{shapes,backgrounds, intersections}

\begin{document}

\begin{tikzpicture}

\begin{scope} [fill opacity = .4]

\draw (-5,5) rectangle (5,-6);

\draw[fill=green, draw = black] (-1.5,1) circle (3);
\draw[fill=blue, draw = black] (1.5,1) circle (3);
\draw[fill=red, draw = black] (0,-2) circle (3);

\begin{scope}
\clip \firstcircle;
\clip \secondcircle;
\draw[fill=white];
\end{scope}

\node at (-4,5.2) {\LARGE\textbf{X}};
\node at (-3,4) {\LARGE\textbf{A}};
\node at (3,4) {\LARGE\textbf{B}};
\node at (-3,-4) {\LARGE\textbf{C}};
\node at (0,0) {\LARGE\textbf{0}};
\node at (0,-1.5) {\small\textbf{SQ}};
\end{scope}

\draw[help lines](-5,5) grid (5,-6);

\end{tikzpicture}

\end{document}][/code]

asmithb
Posts: 4
Joined: Tue Feb 23, 2021 12:04 pm

[\documentclass{article}

\usepackage{tikz}

\RequirePackage{xkeyval}
\RequirePackage{tikz}
\RequirePackage{etoolbox}

\usetikzlibrary{shapes,backgrounds, intersections}

\begin{document}

\begin{tikzpicture}

\begin{scope} [fill opacity = .4]

\draw (-5,5) rectangle (5,-6);

\draw[fill=green, draw = black] (-1.5,1) circle (3);
\draw[fill=blue, draw = black] (1.5,1) circle (3);
\draw[fill=red, draw = black] (0,-2) circle (3);

\begin{scope}
\clip \firstcircle;
\clip \secondcircle;
\draw[fill=white];
\end{scope}

\node at (-4,5.2) {\LARGE\textbf{X}};
\node at (-3,4) {\LARGE\textbf{A}};
\node at (3,4) {\LARGE\textbf{B}};
\node at (-3,-4) {\LARGE\textbf{C}};
\node at (0,0) {\LARGE\textbf{0}};
\node at (0,-1.5) {\small\textbf{SQ}};
\end{scope}

\draw[help lines](-5,5) grid (5,-6);

\end{tikzpicture}

\end{document}

rais
Posts: 280
Joined: Sun Nov 16, 2014 8:51 pm
Your code errs out (neither \firstcircle nor \secondcircle is defined).
Perhaps something like this?
\documentclass{article} \usepackage{tikz} \usetikzlibrary{intersections} \begin{document} \begin{tikzpicture} \begin{scope} [fill opacity = .4] \draw (-5,5) rectangle (5,-6);% name the paths:\path[name path=A, draw, fill=green] (-1.5,1) circle (3) node(NA){};\path[name path=B, draw, fill=blue] (1.5,1) circle (3) node(NB){};\path[name path=C, draw, fill=red] (0,-2) circle (3) node(NC){};\begin{scope}[fill opacity=1]% punch out the intersecting area of cicles A and B:\clip (NB) circle (2.99297);% half the line width smaller than the circle's radius% to keep the circle's line (B) intact.% (= 3cm - 0.2pt * 2.54cm/in / 72.27pt/in)\fill[white] (NA) circle (2.99297);% same here for circle A\end{scope}% end the scope to be able to draw something outside its clip area % get the intersection points between circles A and B:\path[name intersections={of=A and B}];\begin{scope}[fill opacity=1]% put some solid dots at the intersecting points:\fill (intersection-1) circle (3pt) node[above]{$y$}; \fill (intersection-2) circle (3pt) node[below=3pt]{SQ};\end{scope} \node at (-4,5.2) {\LARGE\textbf{X}};\node at (-3,4) {\LARGE\textbf{A}};\node at (3,4) {\LARGE\textbf{B}};\node at (-3,-4) {\LARGE\textbf{C}};\node at (0,0) {\LARGE\textbf{0}};\node at (0,-1.5) {\small\textbf{SQ}};\end{scope} \draw[help lines](-5,5) grid (5,-6); \end{tikzpicture} \end{document}

BTW: you should refrain from using \RequirePackage inside your document. That's more suited for packages / classes. Besides, \usepackage is even less to type

KR
Rainer

asmithb
Posts: 4
Joined: Tue Feb 23, 2021 12:04 pm
Thank you very much!

I have one more question. How could I highlight the intersect area (originally filled in white color) with oblique lines or with other styles (not filled entirely with a color)?

How could I draw the intersect of the 3 circles A, B and C, instead of just A and B (as was done in your code).

Bartman
Posts: 160
Joined: Fri Jan 03, 2020 2:39 pm
Use the \clip command also for the node named NC before the \fill command within the scope environment.