Featured Book

LaTeX Beginners Guide

Who is online

In total there are 14 users online :: 0 registered, 0 hidden and 14 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 14 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

venn diagram

Add tags Information and discussion about graphics, figures & tables in LaTeX documents.

venn diagram

Postby mobearette on Sat Oct 31st, 2009

Hello everyone.

I have some troubles with my LaTeX homework. I should draw a venn diagram looking like this
captureex.png
captureex.png (19.24 KiB) Viewed 5988 times

What I did so far looks like this
blan.png
blan.png (13.73 KiB) Viewed 5988 times

I suppose you see my problem; I don't know how to insert
Code: Select all  •  Open in writeLaTeX
$A \bigcap B
etc on the right place.
Any ideas?

Here is my code
Code: Select all  •  Open in writeLaTeX
\documentclass{article}

\usepackage{tikz
}
%\usetikzlibrary{shapes,backgrounds}

\begin{document}
\pagestyle{empty}

\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(55:2cm) circle (1.5cm)}
\def\thirdcircle{(0:2cm) circle (1.5cm)}

\begin{tikzpicture}[line width=0.25pt]

\begin{scope}
\fill[red] \secondcircle;
\fill[green] \firstcircle;
\fill[blue] \thirdcircle;
\end{scope}

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

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

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

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


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

\end{tikzpicture}

\end{document
}
mobearette
 
Posts: 5
Joined: Sat Oct 31st, 2009

Re: venn diagram

Postby localghost on Sat Oct 31st, 2009

Just place the text as a node like you did with A, B, and C. The pgf/tikZ manual explains that in detail.
Code: Select all  •  Open in writeLaTeX
\node(x,y){$A\cap B\cap C$}


Note: Please upload attachments to the forum server!


Best regards and welcome to the board
Thorsten¹
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses
User avatar
localghost
Site Moderator
 
Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

Re: venn diagram

Postby mobearette on Sat Oct 31st, 2009

localghost wrote:Note: Please upload attachments to the forum server!


Sorry, I didn't know about this rule.

Thx for the quick anwser.
mobearette
 
Posts: 5
Joined: Sat Oct 31st, 2009

Re: venn diagram

Postby localghost on Sat Oct 31st, 2009

mobearette wrote:Sorry, I didn't know about this rule. […]

See Board Rules.

My first reply wasn't thought out very well. So here's the detailed version. In principle you have a radial symmetric construction. Hence it is better to work with polar coordinates because placement of objects is simplified.
Code: Select all  •  Open in writeLaTeX
\documentclass{article}
\usepackage{tikz
}
%\usetikzlibrary{shapes,backgrounds}

\pagestyle{empty}

\def\firstcircle{(90:1.75cm) circle (2.5cm)}
\def\secondcircle{(210:1.75cm) circle (2.5cm)}
\def\thirdcircle{(330:1.75cm) circle (2.5cm)}

\begin{document}
  \begin{tikzpicture}
    \begin{scope}
      \fill[red]\firstcircle;
      \fill[green] \secondcircle;
      \fill[blue] \thirdcircle;
    \end{scope}
    \begin{scope}
      \clip \secondcircle;
      \fill[yellow] \firstcircle;
    \end{scope}
    \begin{scope}
      \clip \secondcircle;
      \fill[cyan] \thirdcircle;
    \end{scope}
    \begin{scope}
      \clip \firstcircle;
      \fill[magenta] \thirdcircle;
    \end{scope}
    \begin{scope}
      \clip \firstcircle;
      \clip \secondcircle;
      \fill[white] \thirdcircle;
    \end{scope}
    \draw \firstcircle node[text=white,above] {$A$};
    \draw \secondcircle node [text=white,below left] {$B$};
    \draw \thirdcircle node [text=white,below right] {$C$};
    \begin{scope}[font=\small]
      \node(0,0) {$A\cap B\cap C$};
      \draw(30:1.5cm) node {$A\cap C$};
      \draw(150:1.5cm) node {$A\cap B$};
      \draw(270:1.5cm) node {$B\cap C$};
    \end{scope}
  \end{tikzpicture}
\end{document
}

The last scope environment consists of all the text that you want to place in this diagram.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses
User avatar
localghost
Site Moderator
 
Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

Re: venn diagram

Postby mobearette on Sat Oct 31st, 2009

Thank you very much. You helped a lot.
mobearette
 
Posts: 5
Joined: Sat Oct 31st, 2009


Return to Graphics, Figures & Tables

Who is online

Users browsing this forum: No registered users and 14 guests