使用 tikz 绘制维恩图中交点的子集

使用 tikz 绘制维恩图中交点的子集

我想从下图中删除:

在此处输入图片描述

顶部圆圈,但不去除将橙色部分与灰色部分分开的黑色边缘。上图是通过以下代码获得的:

\documentclass[border=0.2cm]{standalone}

% Required packages
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}


\begin{document}
\begin{tikzpicture}[thick,
set/.style = {circle,
     minimum size = 3cm,
     fill=black!30}]

% Set A
\node[set,label={135:$A$}] (A) at (0,0) {};

% Set B
\node[set,label={45:$B$}] (B) at (1.8,0) {};
 
% Intersection
\begin{scope}
\clip (0,0) circle(1.5cm);
\clip (1.8,0) circle(1.5cm);
\clip (0.9,1.5) circle(1.5cm);
\fill[orange!60](0,0) circle(1.5cm);
\end{scope}

% Circles outline
\draw (0,0) circle(1.5cm);
\draw (1.8,0) circle(1.5cm);
\draw (0.9,1.5) circle(1.5cm);

\end{tikzpicture}
\end{document}

期望结果的一个粗略示例是:

在此处输入图片描述

答案1

从您的代码中进行微小的更改:使用\draw[fill=orange!60] (0.9,1.5) circle(1.5);和删除\clip (0.9,1.5) circle(1.5cm);

在此处输入图片描述

\documentclass[tikz,border=0.2cm]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
\draw[fill=black!30] 
(0,0) circle(1.5) +(135:1.8) node{$A$} 
(1.8,0) circle(1.5) +(45:1.8) node{$B$};        
% Intersection
\begin{scope}
\clip (0,0) circle(1.5);
\clip (1.8,0) circle(1.5);
\draw[fill=orange!60] (0.9,1.5) circle(1.5);
\end{scope}
        
% Circles outline
\draw (0,0) circle(1.5cm);
\draw (1.8,0) circle(1.5cm);
\end{tikzpicture}
\end{document}

更新这是我的建议:1. 使代码更灵活,更易于控制,使用变量\r作为两个圆的半径,以及\d从两个中心(到原点)的距离;2. 将交点设为鲁洛三角形(看起来更好^^)。

在此处输入图片描述

\documentclass[tikz,border=0.2cm]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
\def\r{1.5} % radius of two circles
\def\d{1}   % distance of two centers
\def\cirA{(210:\d) circle(\r)}
\def\cirB{(-30:\d) circle(\r)}

\draw[fill=violet!30] 
\cirA +(135:\r+.3) node{$A$} 
\cirB +(45:\r+.3)  node{$B$};       

% Fill intersection
\begin{scope}
\clip \cirA;
\clip \cirB;
\draw[fill=yellow] (90:\d) circle(\r);
\end{scope}
        
% Circles outline
\draw \cirA \cirB;
\end{tikzpicture}
\end{document}

相关内容