以特定样式绘制三个圆圈组成的维恩图

以特定样式绘制三个圆圈组成的维恩图

我对 tikz 的了解非常有限。如何将中间的圆圈 (M_3) 向上移动,使其看起来像典型的维恩图?

我目前的进展:

在此处输入图片描述

我迄今为止的代码:

\documentclass{article}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \def\firstcircle{(0,0) circle (1.5cm)}
    \def\secondcircle{(0:2cm) circle (1.5cm)}
    \def\thirdcircle{(0:1cm) circle (1.5cm)}
            
    \colorlet{circle edge}{red!50}
    \colorlet{circle area}{red!20}
            
    \tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
        outline/.style={draw=circle edge, thick}}
            
    \setlength{\parskip}{5mm}

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

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

    \draw[outline] \firstcircle node {$M_1$};
    \draw[outline] \secondcircle node {$M_2$};
    \draw[outline] \thirdcircle node {$M_3$};

    \node[anchor=south] at (current bounding box.north) {$M_1 \cap M_2 \cap M_3$};
\end{tikzpicture}

\end{document}

谢谢你!

答案1

使用极坐标。

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \def\firstcircle {(210:1.1cm) circle (1.5cm)}
    \def\secondcircle{(330:1.1cm) circle (1.5cm)}
    \def\thirdcircle {( 90:1.1cm) circle (1.5cm)}
            
    \colorlet{circle edge}{red!50}
    \colorlet{circle area}{red!20}
            
    \tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
        outline/.style={draw=circle edge, thick}}
            
    \setlength{\parskip}{5mm}

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

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

    \draw[outline] \firstcircle node {$M_1$};
    \draw[outline] \secondcircle node {$M_2$};
    \draw[outline] \thirdcircle node {$M_3$};

    \node[anchor=south] at (current bounding box.north) {$M_1 \cap M_2 \cap M_3$};
\end{tikzpicture}

\end{document}

MWE 输出

(请注意,绘图上方的表达式不适合绘图中的阴影区域。)

答案2

在这个Asymptote解决方案中,我们首先创建一组关键点,然后使用它们作为圆心和相应的圆弧的起点和终点,我们构建一个可寻址的区域边界列表,因此每个区域都可以用不同的方式填充。

相交区域使用的颜色被选择为相应相交区域颜色的平均值。

为了方便起见,显示命名的点。

//
// Venn-diag.asy
//
// run 
//   asy Venn-diag.asy
//
//  to get a standalone  Venn-diag.pdf
//
settings.tex="pdflatex";
size(7cm);
import fontsize;defaultpen(fontsize(8pt));
texpreamble("\usepackage{lmodern}"+"\usepackage{amsmath}"
+"\usepackage{amsfonts}"+"\usepackage{amssymb}");
pair A,B,C,D,E,F,O;
transform t=rotate(120);
O=0;   A=(0,-1/sqrt(3));
B=t*A; C=t*B;
D=A-1; E=A+1; F=2B-E;
guide[] g={arc(A,D,E)&arc(B,E,A,CW)&arc(C,A,D,CW)&cycle,};
g.cyclic=true;
g.push(t*g[-1]);
g.push(t*g[-1]);
g.push(arc(B,A,E)&arc(A,E,B)&arc(C,B,A,CW)&cycle);
g.push(t*g[-1]);
g.push(t*g[-1]);
g.push(arc(C,A,B)&arc(A,B,C)&arc(B,C,A)&cycle);
pen[] fPen={lightred,deepgreen,lightblue,};
fPen.push(0.5*(fPen[0]+fPen[1]));
fPen.push(0.5*(fPen[1]+fPen[2]));
fPen.push(0.5*(fPen[2]+fPen[0]));
fPen.push(1/3*(fPen[0]+fPen[1]+fPen[2]));
for(int i=0;i<fPen.length;++i) fill(g[i],fPen[i]);
draw(circle(A,1),red+.7*bp);      
draw(circle(B,1),deepgreen+.7*bp);
draw(circle(C,1),blue+.7*bp);     
string[] s=array("ABCDEF");
pair[] p={A,B,C,D,E,F,};
dot(p,UnFill);
for(int i=0;i<p.length;++i) label("$"+s[i]+"$",p[i],dir(p[i]));  
pair L=A-(0,1/2);
for(int i=0;i<3;++i)label("$\mathbf M_"+string(i+1)+"$",t^i*L,white); 
L=(A+B+E)/3*1.2;
label("$M_1\cap M_2$",L,white); 
label("$M_2\cap M_3$",t*L,white); 
label("$M_1\cap M_3$",t^2*L,white); 
label("$M_1\cap M_2\cap M_3$",white); 

在此处输入图片描述

答案3

@schtandard 已经回答了我的问题。但是,对于那些正在寻找符合描述的图纸的人,我提供了 @schtandard 解决方案的改编版本:

在此处输入图片描述

\begin{tikzpicture}
    \def\firstcircle {(210:1.1cm) circle (1.5cm)}
    \def\secondcircle{(330:1.1cm) circle (1.5cm)}
    \def\thirdcircle {( 90:1.1cm) circle (1.5cm)}
            
    \colorlet{circle edge}{red!50}
    \colorlet{circle area}{red!20}
            
    \tikzset{filled/.style={fill=circle area, draw=circle edge, thick},
        outline/.style={draw=circle edge, thick}}
            
    \setlength{\parskip}{5mm}
            
    \begin{scope}
        \clip \secondcircle;
        \clip \firstcircle;
        \fill[filled] \thirdcircle;
    \end{scope}
            
    \draw[outline] \firstcircle node {$M_1$};
    \draw[outline] \secondcircle node {$M_2$};
    \draw[outline] \thirdcircle node {$M_3$};
            
    \node[anchor=south] at (current bounding box.north) {$M_1 \cap M_2 \cap M_3$};
\end{tikzpicture}

相关内容