Koohf
Junior Dabei seit: 14.12.2019 Mitteilungen: 18
Themenstart: 2020-01-26
Guten morgen,
Wie kann ich die folgenden Venn Diagramme mit TikZ darstellen.
Mir schwebt eine Kombo aus der matrix Bibliothek, shapes und backgrounds vor.
Slash
Aktiv Dabei seit: 23.03.2005 Mitteilungen: 8180
Herkunft: Cuxhaven-Sahlenburg
Beitrag No.1, eingetragen 2020-01-26
Hi Koohf,
schau mal in diesen Artikel. Dort findest du dieses Beispiel.
LaTeX
<math>\begin{tikzpicture}[scale=1.3]\definecolor{hellgruen}{rgb}{0.6,0.95,0.3}\def\firstcircle{(0,0) circle [radius=8mm]}\def\secondcircle{(0.5,0.866) circle [radius=8mm]}\def\thirdcircle{(1,0) circle [radius=8mm]}\begin{scope}\clip\firstcircle;
\fill[hellgruen]\secondcircle;
\fill[hellgruen]\thirdcircle;
\end{scope}\begin{scope}\clip\secondcircle;
\fill[hellgruen]\thirdcircle;
\end{scope}\draw[thin]\firstcircle;
\draw[thin]\secondcircle;
\draw[thin]\thirdcircle;
\draw node at (-0.2,-0.2) {$a$};
\draw node at (1.2,-0.2) {$b$};
\draw node at (0.5,1.066) {$c$};
\end{tikzpicture}</math>
Gruß, Slash
----------------- Bound to be disappointing so why wait?
Koohf
Junior Dabei seit: 14.12.2019 Mitteilungen: 18
Beitrag No.2, vom Themenstarter, eingetragen 2020-01-26
Hi Slash,
das ist eine tolle Grundlage.
Danke.
jetzt bräuchte ich einen Rahmen um diese Konstruktion. Mal schauen, ob ich das hinkriege.
Danke nochmal.
Edit:
Ich habe hier folgenden Code für den Durchschnitt gefunden. Ich finde, dass das eine gute Grundlage ist.
Jetzt fehlen noch Komplement und Vereinigung.
Latex
\documentclass{letter}\usepackage{tikz}\begin{document}\begin{tikzpicture}[fill=gray]% left hand\scope\clip (-2,-2) rectangle (2,2)
(1,0) circle (1);
\fill (0,0) circle (1);
\endscope% right hand\scope\clip (-2,-2) rectangle (2,2)
(0,0) circle (1);
\fill (1,0) circle (1);
\endscope% outline\draw (0,0) circle (1) (0,1) node [text=black,above]{$A$}
(1,0) circle (1) (1,1) node [text=black,above]{$B$}
(-2,-2) rectangle (3,2) node [text=black,above]{$H$};
\end{tikzpicture}\end{document}
Edit2: ich muss tatsächlich zugeben, dass ich nicht wirklich versteh was in dem Code passiert. Wäre super, wenn jemand mir erklären könnte, was warum so passiert, wie es passiert.
Koohf
Junior Dabei seit: 14.12.2019 Mitteilungen: 18
Beitrag No.3, vom Themenstarter, eingetragen 2020-01-26
Hier scheint ein brauchbares Beispiel zu sein, welches man möglicherweise benutzen könnte.
Man sollte es nur in ein Rechteck setzen, damit man den Bezug zur Grundmenge $\Omega$ hat.
<math>\begin{tikzpicture}[scale=1.3]\definecolor{hellgruen}{rgb}{0.6,0.95,0.3}\def\firstcircle{(0,0) circle [radius=8mm]}\def\secondcircle{(0.5,0.866) circle [radius=8mm]}\def\thirdcircle{(1,0) circle [radius=8mm]}\begin{scope}\clip\firstcircle;
\fill[hellgruen]\secondcircle;
\fill[hellgruen]\thirdcircle;
\end{scope}\begin{scope}\clip\secondcircle;
\fill[hellgruen]\thirdcircle;
\end{scope}\draw[thin]\firstcircle;
\draw[thin]\secondcircle;
\draw[thin]\thirdcircle;
\draw node at (-0.2,-0.2) {$a$};
\draw node at (1.2,-0.2) {$b$};
\draw node at (0.5,1.066) {$c$};
\end{tikzpicture}</math>
2020-01-26 10:30 - Slash in Beitrag No. 1 schreibt:
Hi Koohf,
schau mal in diesen Artikel. Dort findest du dieses Beispiel.
LaTeX
<math>\begin{tikzpicture}[scale=1.3]\definecolor{hellgruen}{rgb}{0.6,0.95,0.3}\def\firstcircle{(0,0) circle [radius=8mm]}\def\secondcircle{(0.5,0.866) circle [radius=8mm]}\def\thirdcircle{(1,0) circle [radius=8mm]}\begin{scope}\clip\firstcircle;
\fill[hellgruen]\secondcircle;
\fill[hellgruen]\thirdcircle;
\end{scope}\begin{scope}\clip\secondcircle;
\fill[hellgruen]\thirdcircle;
\end{scope}\draw[thin]\firstcircle;
\draw[thin]\secondcircle;
\draw[thin]\thirdcircle;
\draw node at (-0.2,-0.2) {$a$};
\draw node at (1.2,-0.2) {$b$};
\draw node at (0.5,1.066) {$c$};
\end{tikzpicture}</math>
Gruß, Slash
Das
\def\firstcircle{(0,0) circle [radius=8mm]}
\def\secondcircle{(0.5,0.866) circle [radius=8mm]}
\def\thirdcircle{(1,0) circle [radius=8mm]}
ist übrigens nicht besonders TikZ-haft, auch wenn es funktioniert.
Man definiert (mit TikZ-Mitteln) Koordinaten und zeichnet mehrfach Auftretendes (bei Bedarf) mit Schleifen.
Zum anderen verwendet man keine absoluten (kartesischen) Koordinaten, man konstruiert.
Die Mittelpunkte der Kreise sind offensichtlich Ecken eines gleichseitigen Dreiecks; also hängt der ganze Graph von einer Kantenlänge (\a) ab (und einem festen Winkel 60°). TikZ kennt im Übrigen auch Polarkoordinaten.
<math> \pgfmathsetmacro{\a}{0.8}\definecolor{hellgruen}{rgb}{0.6,0.95,0.3}\begin{tikzpicture}[font=\footnotesize]\coordinate[] (A) at (0,0);
\coordinate[] (B) at (\a,0);
\coordinate[] (C) at (60:\a);
\foreach\X/\Y in {A/B, A/C, B/C}{\begin{scope}\clip (\X) circle[radius=\a];
\clip (\Y) circle[radius=\a];
\fill[hellgruen] (\Y) circle[radius=\a];
\end{scope}}\foreach[count=\n, evaluate={\N=2*\n+1}]\P in {A,B,C}{\draw[] (\P) circle[radius=\a];
\path[draw=none] (\P) --+ (\N*60+30:0.5*\a) node[]{$\P$};
}%\draw[local bounding box=dreieck] (A) -- (B) -- (C) --cycle; \end{tikzpicture} </math>