如何使用 TikZ 绘制白色且带有彩色数字的相交圆圈?

如何使用 TikZ 绘制白色且带有彩色数字的相交圆圈?

我是乳胶新手,我正在尝试获得这一点: 在此处输入图片描述

经过谷歌搜索后我得到了这个:

在此处输入图片描述

使用此代码:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\title{FUN A3}
\author{12356}
\date{December 2017}
\setlength{\parindent}{0pt}
\begin{document}

\begin{tikzpicture}
 \tikzset{venn circle/.style={draw,circle,minimum 
 width=5.5cm,fill=#1,opacity=0.4}}

\node [venn circle = red] (A) at (0,0) {$0$};
\node [venn circle = blue] (B) at (60:4cm) {$1$};
\node [venn circle = green] (C) at (0:4cm) {$1$};
\node[left] at (barycentric cs:A=1/2,B=1/2 ) {$1$}; 
\node[below] at (barycentric cs:A=1/2,C=1/2 ) {$1$};   
\node[right] at (barycentric cs:B=1/2,C=1/2 ) {$0$};   
\node[below] at (barycentric cs:A=1/3,B=1/3,C=1/3 ){$0$};
\end{tikzpicture}  

如果我把颜色写成白色而不是蓝色或红色,它们就会变得透明,而且我再也看不到任何圆圈了,如果有人能告诉我如何在背景中的数字后面制作出这些黄色和浅绿色,那就太好了。

答案1

只是为了好玩 ...

\documentclass[pstricks,border=1cm]{standalone}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
\pgfforeach \iA/\iB in{90/3,210/2,330/1}{%
    \pscircle(1.2;\iA){2}%
    \rput(2;\iA){\colorbox{green!50}{$S_\iB$}}%
    \rput(!1.5 \iA\space 180 add PtoC){\colorbox{yellow}{$S_\iB$}}%
}
\rput(0,0){\colorbox{yellow}{$S_4$}}
\end{pspicture}
\end{document}

在此处输入图片描述

答案2

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\title{FUN A3}
\author{12356}
\date{December 2017}
\setlength{\parindent}{0pt}
\begin{document}

\begin{tikzpicture}
 \tikzset{venn circle/.style={draw,circle,minimum 
 width=5.5cm}}

\node [venn circle, label={[fill=yellow]center:0}] (A) at (0,0) {};
\node [venn circle, label={[fill=yellow]center:1}] (B) at (60:4cm) {};
\node [venn circle, label={[fill=yellow]center:1}] (C) at (0:4cm) {};
\node[fill=yellow] at (barycentric cs:A=1/2,B=1/2 ) {1}; 
\node[fill=yellow] at (barycentric cs:A=1/2,C=1/2 ) {1};   
\node[fill=yellow] at (barycentric cs:B=1/2,C=1/2 ) {0};   
\node[fill=yellow] at (barycentric cs:A=1/3,B=1/3,C=1/3 ){0};
\end{tikzpicture}  
\end{document}

在此处输入图片描述

答案3

用于紧急情况的 PSTricks 解决方案。

\documentclass[pstricks,border=1cm]{standalone}
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \pscircle(1.2;90){2}
    \pscircle(1.2;210){2}
    \pscircle(1.2;330){2}
    \psset{linestyle=none,fillstyle=solid}
    \psset{fillcolor=yellow}
    \rput(0,0){\psframebox{$S_4$}}
    \rput(1.5;150){\psframebox{$S_1$}}
    \rput(1.5;270){\psframebox{$S_3$}}
    \rput(1.5;30){\psframebox{$S_2$}}
    \psset{fillcolor=green!50}
    \rput(2;90){\psframebox{$S_3$}}
    \rput(2;210){\psframebox{$S_2$}}
    \rput(2;330){\psframebox{$S_1$}}
\end{pspicture}
\end{document}

在此处输入图片描述

相关内容