4

What I am looking to do is to connect particular intersections of a venn diagram in 3 variables, with arrows. So for example, I manipulated the code here: Venn Diagrams and shaded the intersections according to

$(A \wedge B \vee A \wedge C \vee B \wedge C) \wedge \neg (A \wedge B \wedge C)$

What I can't figure out how to do is to label these intersections and connect them with arrows.

Now, I realize the first code sample has a point in it which would correspond to the intersection of A,B, and C - but in case I would like to connect it in the future, I left it in there.

I can get the code to work to display, for example, derived from an answered question here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
%  \node (G) [below right=1cm and 0cm of E] {$G = \{4,5,6,7\}$};
  \node (z) {$Z$};
  \node (xyz) [below=.8 of z] {$X \times Y$};
  \node (x) [below left=.578cm and 1cm of xyz] {$X$};
  \node (y) [below right=.578cm and 1cm of xyz] {$Y$};
  \draw[<->] (z) to node [sloped, above] {$ $} (y);
  \draw[<->] (x) to node [sloped, above] {$ $} (z);
   \draw[<->] (y) to node [sloped, above] {$ $} (x);
  \draw[-] (z) to node {$ $} (xyz);
  \draw[-] (xyz) to node [below] {$\pi_X$} (x);
  \draw[->] (xyz) to node [below] {$\pi_Y$} (y);
\end{tikzpicture}
\end{document}

as well as:

    \documentclass{article}
    \usepackage{tikz}


    \begin{document}
  \def\firstcircle{(0,0) circle (1.5cm)}
    \def\secondcircle{(60:2.1cm) circle (1.5cm)}
    \def\thirdcircle{(0:2.1cm) circle (1.5cm)}
        \begin{figure}[htb]
    \begin{tikzpicture}

        \draw \firstcircle node[below] {$A$};
        \draw \secondcircle node [above] {$B$};
        \draw \thirdcircle node [below] {$C$};

        \begin{scope}
          \clip \firstcircle;
          \fill[pink] \secondcircle;
        \end{scope}

       \begin{scope}
          \clip \secondcircle;
          \fill[pink] \thirdcircle;
        \end{scope}

        \begin{scope}
          \clip \firstcircle;
          \fill[pink] \thirdcircle;
        \end{scope}

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

    \end{tikzpicture}

        \end{figure}
    \end{document}

Thanks for any help,

Brian

5
  • What does the first example have to do with the second? I'm not clear what is wanted here.
    – cfr
    Aug 16, 2015 at 23:11
  • Do note that courtesy (and, in some cases, the law) requires that code you obtain from others should be attributed i.e. you should acknowledge the source of the code you are using and not simply present it as your own original creation! Unless a user explicitly states otherwise, for example, code posted here is subject to a licence which requires attribution. But the main point, in my view, is that it is just rude not to acknowledge your sources.
    – cfr
    Aug 16, 2015 at 23:14
  • Related, apparently: tex.stackexchange.com/questions/258164/….
    – cfr
    Aug 16, 2015 at 23:16
  • 1
    Yep cfr, you got it! I added it to the original question. I absolutely have a lot of respect for the code people write, attempts made, and problems solved. Thus I will definitely keep in mind to reference.
    – Relative0
    Aug 17, 2015 at 15:15
  • No problem. Generally, people just don't think about it until somebody points it out. Then it seems obvious, but that doesn't mean it was obvious before!
    – cfr
    Aug 17, 2015 at 16:54

2 Answers 2

3

Update

After a comment, this seems to be what is required:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\begin{document}
\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(60:2.1cm) circle (1.5cm)}
\def\thirdcircle{(0:2.1cm) circle (1.5cm)}

\begin{figure}[htb]
\begin{tikzpicture}
\begin{scope}
\clip \firstcircle;
\fill[pink] \secondcircle;
\end{scope}

\begin{scope}
\clip \secondcircle;
\fill[pink] \thirdcircle;
\end{scope}

\begin{scope}
\clip \firstcircle;
\fill[pink] \thirdcircle;
\end{scope}

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

\draw[name path=first] \firstcircle node[below] (A) {$A$};
\draw[name path=second] \secondcircle node [above] (B) {$B$};
\draw[name path=third] \thirdcircle node [below] (C) {$C$};

\path[name intersections={of=first and second,by={fs1,fs2}}];
\path[name intersections={of=second and third,by={st1,st2}}];
\path[name intersections={of=third and first,by={tf1,tf2}}];

\node 
  at ( $ (fs2)!0.33!(fs1) $ ) 
  (a) {a};
\node 
  at ( $ (st2)!0.33!(st1) $ ) 
  (b) {b};
\node 
  at ( $ (tf2)!0.33!(tf1) $ ) 
  (c) {c};
\draw[<->,>=latex]
  (fs2) -- (st2);  
\draw[<->,>=latex]
  (st2) -- (tf2);  
\draw[<->,>=latex]
  (tf2) -- (fs2);  
\end{tikzpicture}
\end{figure}

\end{document}

enter image description here

I'm not sure I understand what you want to do. Something like this?

enter image description here

The code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(60:2.1cm) circle (1.5cm)}
\def\thirdcircle{(0:2.1cm) circle (1.5cm)}

\begin{figure}[htb]
\begin{tikzpicture}
\begin{scope}
\clip \firstcircle;
\fill[pink] \secondcircle;
\end{scope}

\begin{scope}
\clip \secondcircle;
\fill[pink] \thirdcircle;
\end{scope}

\begin{scope}
\clip \firstcircle;
\fill[pink] \thirdcircle;
\end{scope}

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

\draw \firstcircle node[below] (A) {$A$};
\draw \secondcircle node [above] (B) {$B$};
\draw \thirdcircle node [below] (C) {$C$};

\node 
  at ( $ (A)!0.5!(B) $ ) 
  (a) {a};
\node 
  at ( $ (B)!0.5!(C) $ ) 
  (b) {b};
\node 
  at ( $ (C)!0.5!(A) $ ) 
  (c) {c};
\draw[<->,>=latex]
  (a) -- (b);  
\draw[<->,>=latex]
  (b) -- (c);  
\draw[<->,>=latex]
  (c) -- (a);  
\end{tikzpicture}
\end{figure}

\end{document}

And, perhaps giving finer control, using the intersection poibts between the circles:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}

\begin{document}
\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(60:2.1cm) circle (1.5cm)}
\def\thirdcircle{(0:2.1cm) circle (1.5cm)}

\begin{figure}[htb]
\begin{tikzpicture}
\begin{scope}
\clip \firstcircle;
\fill[pink] \secondcircle;
\end{scope}

\begin{scope}
\clip \secondcircle;
\fill[pink] \thirdcircle;
\end{scope}

\begin{scope}
\clip \firstcircle;
\fill[pink] \thirdcircle;
\end{scope}

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

\draw[name path=first] \firstcircle node[below] (A) {$A$};
\draw[name path=second] \secondcircle node [above] (B) {$B$};
\draw[name path=third] \thirdcircle node [below] (C) {$C$};

\path[name intersections={of=first and second,by={fs1,fs2}}];
\path[name intersections={of=second and third,by={st1,st2}}];
\path[name intersections={of=third and first,by={tf1,tf2}}];

\node 
  at ( $ (fs2)!0.33!(fs1) $ ) 
  (a) {a};
\node 
  at ( $ (st2)!0.33!(st1) $ ) 
  (b) {b};
\node 
  at ( $ (tf2)!0.33!(tf1) $ ) 
  (c) {c};
\draw[<->,>=latex]
  (a) -- (b);  
\draw[<->,>=latex]
  (b) -- (c);  
\draw[<->,>=latex]
  (c) -- (a);  
\end{tikzpicture}
\end{figure}

\end{document}

enter image description here

3
  • Indeed Gonzalo, thank you. Do you know how one would go about connecting the furthest points of the intersections with lines, so as to create a full triangle. So what I mean is, connecting each of the 3 points in the intersections of A and B, but not C, just where A meets B, along with A and C (but not B), and B and C (but not A). So I suppose this would be a tangent line to A and C (which goes through B), B and C (which goes through A) and A and B (which goes through C), the tangent lines which all terminate at the intersection with the other lines. Thanks though for what you have posted.
    – Relative0
    Aug 17, 2015 at 15:27
  • @user1922184 Please see my updated answer. Is it something like that what you need? If not, please add an image to your question showing the desired result. Aug 17, 2015 at 15:36
  • (+1) for skill in divination ;).
    – cfr
    Aug 17, 2015 at 16:55
1

Here's another possibility which probably isn't what you want as it doesn't include any arrows:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{positioning,backgrounds}
\begin{document}
\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(60:2.1cm) circle (1.5cm)}
\def\thirdcircle{(0:2.1cm) circle (1.5cm)}
\begin{tikzpicture}
  \begin{scope}
    \clip \firstcircle;
    \fill[pink] \secondcircle;
    \fill[pink] \thirdcircle;
  \end{scope}
  \begin{scope}
    \clip \secondcircle;
    \fill[pink] \thirdcircle;
  \end{scope}
  \begin{scope}
    \clip \firstcircle;
    \clip \secondcircle;
    \fill[white] \thirdcircle;
  \end{scope}
  \draw \firstcircle node[below] {$A$};
  \draw \secondcircle node [above] {$B$};
  \draw \thirdcircle node [below] {$C$};
  \node [text=blue] at (30:20mm) {$B\wedge C$};
  \node [text=red, anchor=west, xshift=-2mm] at (90:10mm) {$A\wedge B$};
  \node (m) [text=green!50!black, below] at (0:10.5mm) {$\wedge$};
  \node [above=0pt of m, anchor=south, inner sep=0pt, text=green!50!black] {$A$};
  \node [below=0pt of m, anchor=north, inner sep=0pt, text=green!50!black] {$C$};
  \begin{scope}
    \clip \firstcircle;
    \draw [green!50!black] \thirdcircle;
  \end{scope}
  \begin{scope}
    \clip \thirdcircle;
    \draw [green!50!black] \firstcircle;
  \end{scope}
  \begin{scope}
    \clip \secondcircle;
    \draw [blue] \thirdcircle;
  \end{scope}
  \begin{scope}
    \clip \thirdcircle;
    \draw [blue] \secondcircle;
  \end{scope}
  \begin{scope}
    \clip \secondcircle;
    \draw [red] \firstcircle;
  \end{scope}
  \begin{scope}
    \clip \firstcircle;
    \draw [red] \secondcircle;
  \end{scope}
  \begin{scope}
    \clip \firstcircle;
    \clip \secondcircle;
    \draw [red] \thirdcircle;
  \end{scope}
  \begin{scope}
    \clip \secondcircle;
    \clip \thirdcircle ;
    \draw [blue] \firstcircle;
  \end{scope}
  \begin{scope}
    \clip \firstcircle;
    \clip \thirdcircle ;
    \draw [green!50!black] \secondcircle;
  \end{scope}
  \node (p) [below=17.5mm, fill=pink, inner sep=0pt, text width=5mm, text height=5mm, draw] at (180:15mm) {};
  \node [right=2.5mm of p] {$((A \wedge B) \vee (A \wedge C) \vee (B \wedge C)) \wedge \neg (A \wedge B \wedge C)$};
\end{tikzpicture}
\end{document}

Note that the additional brackets are required to disambiguate the expression, as far as I know: (A \wedge B) \vee C is not equivalent to A \wedge (B \vee C).

labelled

1
  • Not exactly what I wanted, but It does help in the display and useful, thank you.
    – Relative0
    Aug 17, 2015 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .