如何在 TikZ 中绘制此维恩图?

如何在 TikZ 中绘制此维恩图?

我需要画一幅图,如下图所示。哪个包比较适合画这个图,TikZ?

圆代表集合 A,它独立于部分重叠的圆 B 和 C;所有三个集合都在一个矩形 U 中

答案1

PSTricks 解决方案:

\documentclass{article}

\usepackage{pstricks}

\begin{document}

\begin{pspicture}(8,4)
  \large
  \psframe(0,0)(8,4)
  \rput(0.5,0.5){$\mathbf{U}$}
  \pscircle(1.8,2.8){0.7}
  \rput(2.6,3.6){$\mathbf{A}$}
  \pscircle(6.2,2.5){1.3}
  \rput(7.5,3.6){$\mathbf{B}$}
  \pscircle(5.3,1.5){1.3}
  \rput(6.5,0.4){$\mathbf{C}$}
\end{pspicture}

\end{document}

输出

答案2

另一个 TikZ 选项,但没有fit库并且带有辅助样式:

\documentclass[tikz,border=4]{standalone}

\begin{document}

\begin{tikzpicture}[
mcircle/.style={circle,draw,inner sep=#1}
]
\node[mcircle=0.7cm,label={60:$\mathbf{A}$}] 
  (a) at (1,1.5) {};5
\node[mcircle=1.3cm,label={60:$\mathbf{B}$}] 
  (b) at (8.5,1.5) {};
\node[mcircle=1.3cm,label={-60:$\mathbf{C}$}] 
  (c) at (7,0) {};
\draw
  ([shift={(-8pt,8pt)}]a.west|-b.north) rectangle ([shift={(8pt,-8pt)}]b.east|-c.south);
\node at (a.west|-c.south) {$\mathbf{U}$};
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案3

不能让 pstricks 独自回答,顺便说一句,它需要陪伴 ;-)

\documentclass[tikz,border=4]{standalone}
\usetikzlibrary{fit}
\begin{document}
  \begin{tikzpicture}
    \node[circle,draw,inner sep=0.7cm,label={[font=\bfseries]60:A}] (a) at (1,1.5) {};5
    \node[circle,draw,inner sep=1.3cm,label={[font=\bfseries]60:B}] (b) at (8.5,1.5) {};
    \node[circle,draw,inner sep=1.3cm,label={[font=\bfseries]-60:C}] (c) at (7,0) {};
    \node[draw,fit=(a)(b)(c),inner sep=7pt,
                label={[font=\bfseries,shift={(4ex,4ex)}]south west:U}] {};
  \end{tikzpicture}
\end{document}

在此处输入图片描述

答案4

另外一个选择。

\documentclass{scrartcl}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[font=\bfseries]
  \draw (4,2) rectangle (-4,-2) node[above right] {U};
  \draw ( -2,0.8) circle[radius=0.7] +( 50:0.7) node[right] {A};
  \draw (2.5,0.7) circle[radius=1.2] +( 45:1.2) node[right] {B};
  \draw (1.5,-.7) circle[radius=1.2] +(-40:1.2) node[right] {C};
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容