我实际上想重现以下维恩图:
为此,重要的是中央重叠区域为黄色;重现其他重叠颜色也很好......
这是我的尝试,绝对不行……
\documentclass[class=article,border=0pt]{standalone}
\usepackage{tikz}
\def\A{(0,0) circle (4cm)}
\def\B{(1,2) circle (4cm)}
\def\B{(2,0) circle (4cm)}
\begin{document}
\begin{tikzpicture}
\node[circle, fill=blue, opacity=.5, minimum size=4cm] (A) at (0,0) {};
\node[circle, fill=red, opacity=.5, minimum size=4cm] (B) at (1,2) {};
\node[circle, fill=green, opacity=.5, minimum size=4cm] (C) at (2,0) {};
\begin{scope}
\clip \A;
\fill[yellow] \B;
\end{scope}
\end{tikzpicture}
\end{document}
我想在使用 LuaLaTeX 编译的 Beamer 演示文稿中使用它
答案1
这是一个剪辑的解决方案在 tikz 中绘制具有不同颜色的椭圆作为它们的交点?
\documentclass[tikz,border=2mm]{standalone}
\usepackage{xcolor}
\begin{document}
\begin{tikzpicture}[{every node/.style={black,font=\sffamily\Large}}]
\def\firstcircle{(0,0) circle (3cm)}
\def\secondcircle{(3,0) circle (3cm)}
\def\thirdcircle{(1.5,3) circle (3cm)}
\def\boundingbox{(-3,-3) rectangle (6,4.5)}
\definecolor{handsome}{HTML}{C8CADF}
\definecolor{jerk}{HTML}{EF3A43}
\definecolor{batman}{HTML}{FBC405}
\definecolor{dumb}{HTML}{B7CA54}
\definecolor{smart}{HTML}{C7DAC4}
\definecolor{nerd}{HTML}{4C4B6B}
\definecolor{nice}{HTML}{E4B1AD}
\node[font=\huge] at (1.5,6.5) {MEN};
% fill circles
\fill[smart] \firstcircle node[xshift=-1.5cm, yshift=-.5cm] {SMART};
\fill[nice] \secondcircle node[xshift=1.5cm, yshift=-.5cm] {NICE};
\fill[handsome] \thirdcircle node[yshift=1cm] {HANDSOME};
% fill intersections
% intersection of first and second
\begin{scope}
\clip \boundingbox \thirdcircle;
\clip \firstcircle;
\fill[nerd] \secondcircle node[black, xshift=-1.5cm, yshift=-.5cm] {NERD};
\end{scope}
% intersection of first and third
\begin{scope}
\clip \boundingbox \secondcircle;
\clip \firstcircle;
\fill[jerk] \thirdcircle node[xshift=-1.8cm, yshift=-1cm] {JERK};
\end{scope}
% intersection of second and third
\begin{scope}
\clip \boundingbox \firstcircle;
\clip \secondcircle;
\fill[dumb] \thirdcircle node[xshift=1.8cm, yshift=-1cm] {DUMB};
\end{scope}
% intersection of first, second and third
\begin{scope}
\clip \firstcircle;
\clip \secondcircle;
\clip \thirdcircle;
\fill[batman] \boundingbox;
\end{scope}
\node at (1.5,1.2) {X};
\end{tikzpicture}
\end{document}
答案2
这是与 和 交点相关的解决方案pgfplots
。可能有更简单的解决方案(例如使用裁剪),但这可能是一种替代方案。
致谢:蝙蝠侠标志借自这个reddit帖子。
输出
代码
\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{intersections}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.12}
\tikzset{venn circle/.style={draw,circle,minimum width=3cm,draw=none,fill=#1!40,name path=#1}}
\newcommand{\batman}[1]{
\begin{scope}[scale=.07, shift={(#1)}]
\draw[fill,black] (-0.25,1.48) .. controls (-0.1,1.5) and (0.1,1.5) .. (0.25,1.48) -- (0.35,1.92) .. controls (0.425,1.8) and (0.41,1.3) .. (0.45,1.2) .. controls (0.6,1.05) and (1.96,1.05) .. (1.98,2.08) -- (5.93,2.08) .. controls (4.2,1.45) and (4,0.3) .. (4.2,-0.28) .. controls (2.4,-0.09) and (0.4,-0.5) .. (0,-2.052) .. controls (-0.4,-0.5) and (-2.4,-0.09) .. (-4.2,-0.28) .. controls (-4,0.3) and (-4.2,1.45) .. (-5.93,2.08) -- (-1.98,2.08) .. controls (-1.96,1.05) and (-0.6,1.05) .. (-0.45,1.2) .. controls (-0.41,1.3) and (-0.425,1.8) .. (-0.35,1.92) -- (-0.25,1.48);
\end{scope}
}
\begin{document}
\begin{tikzpicture}
\node[font=\Huge\scshape] at (90:3cm) {MEN};
\node [venn circle=green,label={[label distance=-1.5cm]180:Smart}] (A) at (-150:1cm) {};
\node [venn circle=blue,label={[label distance=-1.5cm]90:Handsome}] (B) at (90:1cm) {};
\node [venn circle=red, label={[label distance=-1.5cm]0:Nice}] (C) at (-30:1cm) {};
\fill[red,
intersection segments={
of=green and blue,
sequence={R2--L2}
}];
\fill[blue!50!black,
intersection segments={
of=red and green,
sequence={R1--L2--R0}
}];
\fill[green!50!black,
intersection segments={
of=red and blue,
sequence={R2--L2}
}];
\path [
name path=rag,
intersection segments={
of=green and red,
}];
\fill[yellow,intersection segments={of=blue and rag,sequence=R2--B1}]
[intersection segments={of=rag and blue, sequence={--R2}}];
\node[font=\footnotesize,left,yshift=2mm] at (barycentric cs:A=1/2,B=1/2 ) {Jerk};
\node[font=\footnotesize,below,yshift=-2mm] at (barycentric cs:A=1/2,C=1/2 ) {Nerd};
\node[font=\footnotesize,right,xshift=-1mm,yshift=2mm] at (barycentric cs:B=1/2,C=1/2 ) {Dumb};
\batman{barycentric cs:A=1/3,B=1/3,C=1/3}
\end{tikzpicture}
\end{document}
答案3
path picture
以下是使用as选项的建议node
:
\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
kreis/.style={circle,fill=#1,minimum size=4cm},kreis/.default=none
]
\def\tshift{.2cm}
\path
(0,0) coordinate (A)
(1,2) coordinate (B)
(2,0) coordinate (C)
;
\path
(A)
node [kreis=green!20]{}
node [below left=\tshift and \tshift] {SMART}
(B)
node [kreis=blue!20,
path picture={\node[kreis=red!80!black!60] at (A){};}]{}
node [above=\tshift] {HANDSOME}
(C)
node [kreis=red!20,
path picture={
\node[kreis=blue!50!red!80!black!70] at (A){};
\node[kreis=green!80!black!60,
path picture={\node[kreis=yellow] at (A){};}
] at (B){};}]{}
node [below right=\tshift and \tshift]{NICE}
;
\path
(1,0) node [below=\tshift]{NERD}
(1,1) node [above left=\tshift and 2.5*\tshift] {JERK}
node [above right=\tshift and 2.5*\tshift]{DUMB}
node [yshift=-\tshift,font=\Huge]{X}
;
\end{tikzpicture}
\end{document}