2

In order to to independently control the color of the overlap between two circles using \clip, it seems I must use the \draw command, as illustrated at http://www.texample.net/tikz/examples/venn-diagram/ (and below). However, the circle is then not a node, meaning that I can't draw an arrow from its edge. Is there a way to do this? My current code produces an undesired arrow from the center:

\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}

Two circles with colored overlap, arrows from center rather than edge

2

2 Answers 2

1

You can still clip if you use \nodes:

enter image description here

Code:

\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
  • Thank you. I selected this because it requires the minimum amount of differences from what I was using before (it actually uses \clip, as I had done).
    – sautedman
    Jan 5, 2015 at 21:41
  • Perhaps this should be a separate question, but how can this be extended to ellipses? Specifying the sizes for the clipping ellipses \A and \B is totally opaque to me. I have tried \def\A{(0,0) ellipse (2*\MyRadius and \MyRadius)} only to get an error. Specifying minimum width and height in square brackets removes the color!
    – sautedman
    Jan 6, 2015 at 18:02
2

You can clip inside node with path picture key, like this:

\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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .