벤 다이어그램 사용자 정의

벤 다이어그램 사용자 정의

내 작업에는 세 개의 원이 있고 교차하는 부분이 선으로 두 개로 나누어진 벤 다이어그램이 필요합니다.여기에 이미지 설명을 입력하세요

Tex.SE의 답변을 사용했는데, 이를 어떻게 사용하여 그림과 같이 사이에 선을 그리고, 음영처리를 하는지 모르겠습니다. 누군가 나를 도와줄 수 있나요?

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \tikzset{venn circle/.style={draw,circle,minimum width=6cm,fill=#1,opacity=0.4}}

  \node [venn circle = red] (A) at (0,0) {$A$};
  \node [venn circle = blue] (B) at (60:4cm) {$B$};
  \node [venn circle = green] (C) at (0:4cm) {$C$};
  \node[left] at (barycentric cs:A=1/2,B=1/2 ) {$A \cap B$}; 
  \node[below] at (barycentric cs:A=1/2,C=1/2 ) {$A \cap C$};   
  \node[right] at (barycentric cs:B=1/2,C=1/2 ) {$B \cap C$};   
  \node[below] at (barycentric cs:A=1/3,B=1/3,C=1/3 ){$A \cap B \cap C$};
\end{tikzpicture}  
\end{document}

여기에 이미지 설명을 입력하세요

답변1

아마도 좀 더 다듬을 수 있겠지만, 이것이 기본적으로 귀하의 질문에 대한 답이 될 것이라고 생각합니다. 당신이 해야 할 일은 작업하고 원하는 패턴이나 채우기를 만드는 데 사용할 수 있는 경로를 구성하는 것입니다. 따라서 원의 교차점을 계산하여 좌표에 전달합니다. 이 좌표를 사용하여 원의 중심과 교차점 사이의 각도를 계산하고 최종적으로 호를 사용하여 채우려는 모양을 만들 수 있습니다. A, B, C의 중첩 영역을 분리하는 교차선을 생성하려면 기본적으로 원 B의 교차점과 A, C의 두 교차점 사이의 선을 계산합니다.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}
  \tikzset{venn circle/.style={draw,circle,minimum width=6cm,fill=#1,opacity=0.4,text opacity=1}}

  \node [name path=A, venn circle = red] (A) at (0,0) {$A$};
  \node [name path=B, venn circle = blue] (B) at (60:4cm) {$B$};
  \node [name path=C, venn circle = green] (C) at (0:4cm) {$C$};

    % intersection points between circles A and B
    \path [name intersections={of = A and B}];
    \coordinate (AB1)  at (intersection-1);
    \coordinate (AB2)  at (intersection-2);

    % intersection points between circles B and C
    \path [name intersections={of = B and C}];
    \coordinate (BC1)  at (intersection-1);
    \coordinate (BC2)  at (intersection-2);

    % intersection points between circles A and C
    \path [name intersections={of = A and C}];
    \coordinate (AC1)  at (intersection-1);
    \coordinate (AC2)  at (intersection-2);

    % constructing path from AC1 to AC2 and calculating intersection point with circle B
    \path [name path=AC] (AC1)--(AC2);
    \path [name intersections={of = AC and B}];
    \coordinate (ACB1)  at (intersection-1);

    % calculate angles from center of A/B to intersection points
    \pgfmathanglebetweenpoints{\pgfpointanchor{A}{center}}{\pgfpointanchor{AB2}{center}}
    \let\AABtwo\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{A}{center}}{\pgfpointanchor{AC1}{center}}
    \let\AACone\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{B}{center}}{\pgfpointanchor{AB2}{center}}
    \let\BABtwo\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{B}{center}}{\pgfpointanchor{ACB1}{center}}
    \let\BACBone\pgfmathresult

    % calculate angles from center of B/C to intersection points
    \pgfmathanglebetweenpoints{\pgfpointanchor{B}{center}}{\pgfpointanchor{ACB1}{center}}
    \let\CACBone\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{B}{center}}{\pgfpointanchor{BC2}{center}}
    \let\BBCtwo\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{C}{center}}{\pgfpointanchor{AC1}{center}}
    \let\CACone\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{C}{center}}{\pgfpointanchor{BC2}{center}}
    \let\CBCtwo\pgfmathresult

    % calculate angles from center of A/C to intersection points
    \pgfmathanglebetweenpoints{\pgfpointanchor{A}{center}}{\pgfpointanchor{AC1}{center}}
    \let\AACone\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{A}{center}}{\pgfpointanchor{AC2}{center}}
    \let\AACtwo\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{C}{center}}{\pgfpointanchor{AC1}{center}}
    \let\CACone\pgfmathresult

    \pgfmathanglebetweenpoints{\pgfpointanchor{C}{center}}{\pgfpointanchor{AC2}{center}}
    \let\CACtwo\pgfmathresult

    % draw patterns
    \pattern[pattern=horizontal lines, pattern color=red]
    (AB2) arc[start angle=\AABtwo, end angle=\AACone,radius=3cm] -- (ACB1) --
    (ACB1) arc[start angle=\BACBone, end angle=\BABtwo,radius=3cm]; 

    \pattern[pattern=horizontal lines, , pattern color=blue]
    (BC2) arc[start angle=\BBCtwo, end angle=\BACBone,radius=3cm] -- (AC1)
    (AC1) arc[start angle=\CACone, end angle=\CBCtwo,radius=3cm];

    % draw separation line
    \draw [thick] (AC1)--(ACB1);

    % print annotations
  \node[left, fill=white, fill opacity=0.5, text opacity=1, inner sep=1.5pt]
    at (barycentric cs:A=1/2,B=1/2 ) {$A \cap B$}; 
  \node[below, fill=white, fill opacity=0.5, text opacity=1, inner sep=1.5pt]
    at (barycentric cs:A=1/2,C=1/2 ) {$A \cap C$};   
  \node[right, fill=white, fill opacity=0.5, text opacity=1, inner sep=1.5pt]
    at (barycentric cs:B=1/2,C=1/2 ) {$B \cap C$};   
  \node[below, fill=white, fill opacity=0.5, text opacity=1, inner sep=1.5pt]
    at (barycentric cs:A=1/3,B=1/3,C=1/3 ){$A \cap B \cap C$};
\end{tikzpicture}  
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보