为了使用 \clip 独立控制两个圆之间重叠的颜色,似乎我必须使用 \draw 命令,如下图所示http://www.texample.net/tikz/examples/venn-diagram/(及以下)。但是,圆圈不是节点,这意味着我无法从其边缘绘制箭头。有办法吗?我当前的代码从中心产生了一个不想要的箭头:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\def\A{(0,0) circle (2cm)}
\def\B{(3,0) circle (2cm)}
\begin{tikzpicture}
\draw \A node[](A){};
\draw \B node[](B){};
\begin{scope}
\clip \A;
\fill[green, opacity=0.2] \B;
\end{scope}
\node(nom)at(0,-3) {[A]};
\node(gen)at(3,-3) {[B]};
\draw[->] (A) -- (nom);
\draw[->] (B) -- (gen);
\end{tikzpicture}
\end{document}
答案1
如果您使用,您仍然可以剪辑\nodes
:
代码:
\documentclass{article}
\usepackage{tikz}
\newcommand*{\MyRadius}{2cm}
\def\A{(0,0) circle (\MyRadius)}
\def\B{(3,0) circle (\MyRadius)}
\begin{document}
\begin{tikzpicture}
\node[draw, shape=circle, minimum width=2*\MyRadius, ultra thick] (A) at (0,0) {};
\node[draw, shape=circle, minimum width=2*\MyRadius, ultra thick] (B) at (3,0) {};
\begin{scope}
\clip \A;
\fill[green, opacity=0.2] \B;
\end{scope}
\node(nom) at (0,-3) {[A]};
\node(gen) at (3,-3) {[B]};
\draw[->] (A) -- (nom);
\draw[->] (B) -- (gen);
\end{tikzpicture}
\end{document}
答案2
您可以使用键剪切内部节点path picture
,如下所示:
\documentclass[tikz,border=1cm]{standalone}
\usetikzlibrary{calc}
\tikzset{
mycircle/.style={circle,minimum width=4cm}
}
\begin{document}
\begin{tikzpicture}
\node[mycircle,draw, path picture={
\node[mycircle,fill=green,opacity=0.2] at (3,0){};
}] (A){};
\node[mycircle,draw] (B) at (3,0){};
\node(nom) at (0,-3) {[A]};
\node(gen) at (3,-3) {[B]};
\draw[->] (A) -- (nom);
\draw[->] (B) -- (gen);
\end{tikzpicture}
\end{document}