LaTeX forum ⇒ Graphics, Figures & TablesVenn Diagrams and Intersection Points

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

Venn Diagrams and Intersection Points

Postby asmithb » Tue Feb 23, 2021 12:14 pm

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
VPs.png (118.38 KiB) Viewed 129 times

Bartman
Posts: 159
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Tue Feb 23, 2021 6:43 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: 3
Joined: Tue Feb 23, 2021 12:04 pm

Postby asmithb » Thu Feb 25, 2021 10:27 am

Could you please help me? So far I have just made the following Venn diagram and labeled the point SQ:

[\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: 3
Joined: Tue Feb 23, 2021 12:04 pm

Postby asmithb » Thu Feb 25, 2021 10:29 am

Could you please help me? So far I have just made the following Venn diagram and labeled the point SQ:

[\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

Postby rais » Fri Feb 26, 2021 7:44 pm

Your code errs out (neither \firstcircle nor \secondcircle is defined).
Perhaps something like this?
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2.  
  3. \usepackage{tikz}
  4.  
  5. \usetikzlibrary{intersections}
  6.  
  7. \begin{document}
  8.  
  9. \begin{tikzpicture}
  10.  
  11. \begin{scope} [fill opacity = .4]
  12.  
  13. \draw (-5,5) rectangle (5,-6);
  14. % name the paths:
  15. \path[name path=A, draw, fill=green] (-1.5,1) circle (3) node(NA){};
  16. \path[name path=B, draw, fill=blue] (1.5,1) circle (3) node(NB){};
  17. \path[name path=C, draw, fill=red] (0,-2) circle (3) node(NC){};
  18. \begin{scope}[fill opacity=1]% punch out the intersecting area of cicles A and B:
  19. \clip (NB) circle (2.99297);% half the line width smaller than the circle's radius
  20. % to keep the circle's line (B) intact.
  21. % (= 3cm - 0.2pt * 2.54cm/in / 72.27pt/in)
  22. \fill[white] (NA) circle (2.99297);% same here for circle A
  23. \end{scope}% end the scope to be able to draw something outside its clip area
  24.  
  25. % get the intersection points between circles A and B:
  26. \path[name intersections={of=A and B}];
  27. \begin{scope}[fill opacity=1]% put some solid dots at the intersecting points:
  28. \fill (intersection-1) circle (3pt) node[above]{$y$};
  29. \fill (intersection-2) circle (3pt) node[below=3pt]{SQ};
  30. \end{scope}
  31.  
  32. \node at (-4,5.2) {\LARGE\textbf{X}};
  33. \node at (-3,4) {\LARGE\textbf{A}};
  34. \node at (3,4) {\LARGE\textbf{B}};
  35. \node at (-3,-4) {\LARGE\textbf{C}};
  36. \node at (0,0) {\LARGE\textbf{0}};
  37. \node at (0,-1.5) {\small\textbf{SQ}};
  38. \end{scope}
  39.  
  40. \draw[help lines](-5,5) grid (5,-6);
  41.  
  42. \end{tikzpicture}
  43.  
  44. \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


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 7 guests