tikz,四个圆的交点没有任何填充,但有文字

tikz,四个圆的交点没有任何填充,但有文字

嘿,

我对下图有疑问。我希望所有四个圆的交点都是白色的,不是填充的而是透明的,因为交点处必须有文字。我很感激任何想法......

另一个问题是,如何插入更多用白色背景填充的“文本框”,但放置它们的交叉点保持不变。

非常感谢! :)

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}
\usepackage{verbatim}
\begin{document}

\def\firstcircle{(0,0) circle (3 cm)}
\def\secondcircle{(45:2cm) circle (3 cm)}
\def\thirdcircle{(0:3cm) circle (3 cm)}
\def\fourthcircle{(-45:2cm) circle (3 cm)}

\begin{tikzpicture}
\draw \firstcircle node[below] {$$};
\draw \secondcircle node [above] {$$};
\draw \thirdcircle node [below] {$$};
\draw \fourthcircle node [below] {$$};

\node[draw,text width=2.5cm] at (1.5,0) {some text spanning three lines with automatic line breaks};

\begin{scope}[shift={(0cm,0cm)}, fill opacity=0.4]
   \fill[red] \firstcircle;
    \fill[black!30!green] \secondcircle;
    \fill[black!30!blue] \thirdcircle;
    \fill[black!30!violet] \fourthcircle;
   \draw \firstcircle node[below] {$$};
    \draw \secondcircle node [above] {$$};
    \draw \thirdcircle node [below] {$$};
    \draw\fourthcircle node[below]{$$};

 \draw \firstcircle node [anchor=south] at (current bounding box.north {Crassostrea gigas};
 \draw \secondcircle node [anchor=north] at (current bounding box.south) {Mytilus edulis};
 \draw \thirdcircle node [anchor=west] at (current bounding box.east) {Helix pomatia};
 \draw \fourthcircle node[anchor=east] at (current bounding box.west) {Loligo forbesi};     
 \end{scope}

 %    \begin{scope}
 %      \clip \firstcircle;
 %      \clip \secondcircle;
 %      \clip \thirdcircle;
 %      \fill[white]\fourthcircle;
 %    \end{scope}

 \end{tikzpicture}
 \end{document}`

有结果,但交叉口仍被填满:​​(

答案1

这是一个解决方案。一些多余的绘制用 % 标记。文本节点之前的最后 4 次绘制是重新绘制白色区域的轮廓。

在此处输入图片描述

代码

\documentclass[border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}
\usepackage{verbatim}
\begin{document}

\def\firstcircle {(0,0)    circle (3 cm)}
\def\secondcircle{(45:2cm) circle (3 cm)}
\def\thirdcircle {(0:3cm)  circle (3 cm)}
\def\fourthcircle{(-45:2cm)circle (3 cm)}

\begin{tikzpicture}
%\draw \firstcircle node[below] {$$};
%\draw \secondcircle node [above] {$$};
%\draw \thirdcircle node [below] {$$};
%\draw \fourthcircle node [below] {$$};

\begin{scope}[shift={(0cm,0cm)}, fill opacity=0.4]
    \fill[red]            \firstcircle;
    \fill[black!30!green] \secondcircle;
    \fill[black!30!blue]  \thirdcircle;
    \fill[black!30!violet]\fourthcircle;
%\end{scope}          % <-- Move the \end{scope} to here for clear labels.
%   \draw \firstcircle  node[below] {$$};
%   \draw \secondcircle node [above] {$$};
%   \draw \thirdcircle  node [below] {$$};
%   \draw\fourthcircle  node[below]{$$};
 \draw \firstcircle  node [anchor=south] at (current bounding box.north) {Crassostrea gigas};
 \draw \secondcircle node [anchor=north] at (current bounding box.south) {Mytilus edulis};
 \draw \thirdcircle  node [anchor=west] at (current bounding box.east) {Helix pomatia};
 \draw \fourthcircle node[anchor=east] at (current bounding box.west) {Loligo forbesi};     
 \end{scope}          % <-- move this line up will get a clear labels for circle names. It has opacity=0.4 currently.

 \begin{scope}
   \clip \firstcircle;
   \clip \secondcircle;
   \clip \thirdcircle;
   \fill[white]\fourthcircle;
 \end{scope}
  \draw \firstcircle;
  \draw \secondcircle;
  \draw \thirdcircle;
  \draw \fourthcircle;
  \node[draw,text width=2.5cm] at (1.5,0) {some text spanning three lines with automatic line breaks};
 \end{tikzpicture}
 \end{document}

相关内容