使用tikz

时间:2018-03-16 03:36:09

标签: latex nodes intersection tikz

我已经创建了一个社交图,如下所示,但无法找到一种方法将节点放在两个圆圈中,其中中间的节点(F,D,K,M)放置在两个圆圈的交集。

是否有一种标记左圆,右圆和交叉点的简单方法?

以下是代码,并提前感谢您:

\begin{tikzpicture}
\begin{scope}[every node/.style={circle,thick,draw}]
    \node (A) at (0,0) {A};
    \node (B) at (0,3) {B};
    \node (C) at (2,3) {C};
    \node (E) at (1,-1.5) {E};
    \node (G) at (1,1.5) {G};

    \node (F) at (5,2) {F} ;
    \node (D) at (4,1) {D};
    \node (K) at (5,0) {K};
    \node (M) at (4,-1) {M};

    \node (H) at (8.5,0) {H};
    \node (I) at (9,2.5) {I};
    \node (J) at (8,1.5) {J};
    \node (N) at (7.5,-1.5) {N};
    \node (L) at (7,3) {L} ;
    \node (Q) at (9.5,1) {Q} ;
\end{scope}

\begin{scope}[>={Stealth[black]},
    every node/.style={fill=white,circle},
    every edge/.style={draw=red,very thick}]
    \draw (A) -> (G);
    \draw (B) -- (A);
    \draw (B) -- (C);
    \draw (B) -- (G);
    \draw (E) -- (G);
    \draw (E) -- (A);
    \draw (G) -- (C);
    \draw (L) -- (I);
    \draw (H) -- (J);
    \draw (Q) -- (H);
    \draw (I) -- (J);
    \draw (N) -- (H);
    \draw (Q) -- (J);

    \draw (A) -> (D);
    \draw (E) -- (M);
    \draw (E) -- (D);
    \draw (G) -- (D);
    \draw (G) -- (F);
    \draw (C) -- (F);
    \draw (C) -- (M);
    \draw (N) -- (K);
    \draw (N) -- (F);
    \draw (N) -- (M);
    \draw (L) -- (F);
    \draw (J) -- (F);
    \draw (H) -- (F);
\end{scope}
\end{tikzpicture}

更新:

我添加了这两行之后:

\ draw(2,0.7)circle(4cm);

\ draw(7,0.7)圈(4cm);  我明白了: enter image description here

我只留下着色交叉点,所以在我添加的这两行之下:

%\画夹圈(4cm);

%\ fill [gray](2,0.7)circle(4cm);

这项工作完成了,但其中一个圈子隐藏了它的节点!! enter image description here

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我认为这就是你要找的东西:

\begin{tikzpicture}

\begin{scope}
    \draw (2,0.7) circle (4cm);
    \clip (7,0.7) circle (4cm);
    \fill[gray] (2,0.7) circle (4cm);
    \draw (7,0.7) circle (4cm);
\end{scope}

\node[below=4.5cm of circle1] {Circle 1};
\node[below=4.5cm of circle2] {Circle 2};
\node[below=4cm of circle1,xshift=2.5cm] {Intersection};

\begin{scope}[every node/.style={circle,thick,draw}]
    \node (A) at (0,0) {A};
    \node (B) at (0,3) {B};
    \node (C) at (2,3) {C};
    \node (E) at (1,-1.5) {E};
    \node (G) at (1,1.5) {G};

    \node (F) at (5,2) {F} ;
    \node (D) at (4,1) {D};
    \node (K) at (5,0) {K};
    \node (M) at (4,-1) {M};

    \node (H) at (8.5,0) {H};
    \node (I) at (9,2.5) {I};
    \node (J) at (8,1.5) {J};
    \node (N) at (7.5,-1.5) {N};
    \node (L) at (7,3) {L} ;
    \node (Q) at (9.5,1) {Q} ;
\end{scope}

\begin{scope}[>={Stealth[black]},
    every node/.style={fill=white,circle},
    every edge/.style={draw=red,very thick}]
    \draw (A) -> (G);
    \draw (B) -- (A);
    \draw (B) -- (C);
    \draw (B) -- (G);
    \draw (E) -- (G);
    \draw (E) -- (A);
    \draw (G) -- (C);
    \draw (L) -- (I);
    \draw (H) -- (J);
    \draw (Q) -- (H);
    \draw (I) -- (J);
    \draw (N) -- (H);
    \draw (Q) -- (J);

    \draw (A) -> (D);
    \draw (E) -- (M);
    \draw (E) -- (D);
    \draw (G) -- (D);
    \draw (G) -- (F);
    \draw (C) -- (F);
    \draw (C) -- (M);
    \draw (N) -- (K);
    \draw (N) -- (F);
    \draw (N) -- (M);
    \draw (L) -- (F);
    \draw (J) -- (F);
    \draw (H) -- (F);
\end{scope}
\end{tikzpicture}

enter image description here

在没有看到你如何添加剪辑和填充说明的情况下,我无法真正告诉你什么是错的。