1

Consider the following MWE, which produces the Venn diagram below:

\documentclass[12pt]{article}

\usepackage{tikz,pstricks,pst-jtree}
% pst-jtree enables the \multiline \cr \endmultiline syntax
\usetikzlibrary{shapes,backgrounds}

\begin{document}

\begin{center}
\begin{center}
  \def\first{(0,0) ellipse (6em and 4em)}
  \def\second{(2.7,0) ellipse (6em and 4em)}
  \def\third{(1.45,1.5) ellipse (6em and 4em)}
  \begin{tikzpicture}
    \draw \first node [below] { };
    \draw \second node [below] { };
    \draw \third node [above] { };

    % first coordinate control x axis, second controls y axis
    \node at (-1.1,-.3) (A) {first};
    \node at (3.8,-.5) (B) {second};
    \node at (2.1,.8) (C) {\multiline we care\cr about this\endmultiline};
    \node at (1.5,2.5) (C) {third};

    \begin{scope}[fill opacity = .5]
      \clip \third;
      \fill[light-gray] \second;
    \end{scope}
  \end{tikzpicture}
\end{center}

\end{center}

\end{document}

enter image description here

For aesthetic reasons, I don't want the line of the first ellipse to interfere with the we care about this legend. Is it possible to eliminate the arc of first in the shaded area?

  • \fill first with a white color with no opacity, and then the light-gray with opacity as you wish. – Manuel Jun 29 '15 at 17:41
5

Just change the drawing order:

  1. First ellipse
  2. Gray area
  3. Second and third ellipses and text nodes.

Further remarks:

  • Multi-line text is enabled by node option align.

  • light-gray is a little an unhappy color name because of the hyphen. When the shorthand notation \fill[light-gray] is used, TikZ misinterprets the hyphen as arrow specification, when the color is undefined (as in the example of the question). TikZ complains about an unknown arrow tip light instead of an undefined color error as for fill=light-gray or an unknown key.

Example file:

\documentclass[12pt]{article}

\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}
\begin{center}
  \def\first{(0,0) ellipse (6em and 4em)}
  \def\second{(2.7,0) ellipse (6em and 4em)}
  \def\third{(1.45,1.5) ellipse (6em and 4em)}
  \begin{tikzpicture}
    \draw \first node [below] { };
    \begin{scope}
      \clip \third;
      \fill[lightgray] \second;
    \end{scope}
    \draw \second node [below] { };
    \draw \third node [above] { };

    % first coordinate control x axis, second controls y axis
    \node at (-1.1,-.3) (A) {first};
    \node at (3.8,-.5) (B) {second};
    \node[align=center] at (2.1,.8) (C) {we care\\ about this};
    \node at (1.5,2.5) (C) {third};
  \end{tikzpicture}
\end{center}
\end{document}

Result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.