具有不透明度的 Tikz 思维导图,与维恩图不同的方法

具有不透明度的 Tikz 思维导图,与维恩图不同的方法

我需要为一些特殊集合绘制维恩图。例如,在这些集合中,我知道其中一些集合的交集是空的,所以我想绘制一个特殊的维恩图,省略这些空的交集。

我制作了一个图,其中每个顶点都是一个集合或集合的交集。然后我删除了有空交集的顶点。这样我就可以得到每个顶点的坐标。

使用思维导图,我可以制作一个修改过的维恩图。但它们似乎不够好。它们之间的连接很小(有一个装饰叫做“圆形连接条”,但我不知道如何使用它来修改节点概念)。下面是一个可能性的简单示例。

我只是想得到一些建议,关于我应该改变哪些参数来让它看起来更好。或者也许彻底改变,也许中间地图不是最好的方法。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{mindmap}

\begin{document}

\begin{tikzpicture}[small mindmap,scale=4,opacity=0.4]
\coordinate (A)   at (2.00003,0.882642);
\coordinate (AB)  at (1.49021,1.74189);
\coordinate (AC)  at (1.50998,0.0102365);
\coordinate (ABC) at (1.00055,0.8711);
\coordinate (B)   at (0.490009,1.73215);
\coordinate (BC)  at (0.,0.860431);
\coordinate (C)   at (0.510476,0.);
% The links between the sets.
% In this notation AB means the intersection of A with B.
\path [concept color=red]
    node [concept] at (A) {}
        child  {node [concept] at (AB) {}}
        child  {node [concept] at (AC) {}}
        child  {node [concept] at (ABC) {}};
\path [concept color=blue]
    node [concept] at (B) {}
        child  {node [concept] at (AB) {}}
        child  {node [concept] at (BC) {}}
        child  {node [concept] at (ABC) {}};
\path [concept color=green]
    node [concept] at (C) {}
        child  {node [concept] at (AC) {}}
        child  {node [concept] at (BC) {}}
        child  {node [concept] at (ABC) {}};
% Place the label later, otherwith they got transparent
\path [opacity=1]
    node at (A) {$A$}
    node at (B) {$B$}
    node at (C) {$C$}
    node at (AB) {$A \cap B$}
    node at (AC) {$A \cap C$}
    node at (BC) {$B \cap C$}
    node at (ABC) {$A \cap B \cap C$};
\end{tikzpicture}

\end{document}

答案1

这样怎么样:我使用六边形节点而不是圆形。您只需设置颜色和间隔,连接将自动计算为它们连接的节点的平均颜色。可以为节点分配两种样式之一,vennunvennvenn绘制节点时,使其透明。使用时unvenn无需删除,此参数在定义中根本不使用。=some colorunvennunvenn

代码

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes}

\pgfdeclarelayer{background layer}
\pgfsetlayers{background layer,main}

\begin{document}

\colorlet{abccolor}{gray!50}
\colorlet{acolor}{red!50!gray}
\colorlet{abco\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes}

\pgfdeclarelayer{background layer}
\pgfsetlayers{background layer,main}

\begin{document}

\colorlet{abccolor}{gray!50}
\colorlet{acolor}{red!50!gray}
\colorlet{abcolor}{orange!50!gray}
\colorlet{bcolor}{yellow!50!gray}
\colorlet{bccolor}{green!50!gray}
\colorlet{ccolor}{blue!50!gray}
\colorlet{accolor}{violet!50!gray}

\pgfmathsetmacro{\nodescenterseparation}{4}

\begin{tikzpicture}
[   venn/.style={regular polygon, regular polygon sides=6,shape border rotate=30, minimum width=3cm,draw,inner sep=0,fill=#1,draw=#1!70!black,very thick},
    unvenn/.style={regular polygon, regular polygon sides=6,shape border rotate=30, minimum width=3.5cm,opacity=0},
]
    \node[venn=abccolor] at (0,0) (abc) {$A\cap B\cap C$};
    \node[venn=acolor] at (0:\nodescenterseparation) (a) {$A$};
    \node[venn=abcolor] at (60:\nodescenterseparation) (ab) {$A\cap B$};
    \node[venn=bcolor] at (120:\nodescenterseparation) (b) {$B$};
    \node[venn=bccolor] at (180:\nodescenterseparation) (bc) {$B\cap C$};
    \node[venn=ccolor] at (240:\nodescenterseparation) (c) {$C$};
    \node[venn=accolor] at (300:\nodescenterseparation) (ac) {$A\cap C$};

    \begin{pgfonlayer}{background layer}
        \fill[abccolor!50!acolor] (abc.corner 6) -- (abc.center) -- (abc.corner 5) -- (a.corner 3) -- (a.center) -- (a.corner 2) -- cycle;
        \fill[abccolor!50!abcolor] (abc.corner 1) -- (abc.center) -- (abc.corner 6) -- (ab.corner 4) -- (ab.center) -- (ab.corner 3) -- cycle;
        \fill[abccolor!50!bcolor] (abc.corner 2) -- (abc.center) -- (abc.corner 1) -- (b.corner 5) -- (b.center) -- (b.corner 4) -- cycle;
        \fill[abccolor!50!bccolor] (abc.corner 3) -- (abc.center) -- (abc.corner 2) -- (bc.corner 6) -- (bc.center) -- (bc.corner 5) -- cycle;
        \fill[abccolor!50!ccolor] (abc.corner 4) -- (abc.center) -- (abc.corner 3) -- (c.corner 1) -- (c.center) -- (c.corner 6) -- cycle;
        \fill[abccolor!50!accolor] (abc.corner 5) -- (abc.center) -- (abc.corner 4) -- (ac.corner 2) -- (ac.center) -- (ac.corner 1) -- cycle;

        \fill[acolor!50!abcolor] (a.corner 2) -- (a.center) -- (a.corner 1) -- (ab.corner 5) -- (ab.center) -- (ab.corner 4) -- cycle;
        \fill[abcolor!50!bcolor] (ab.corner 3) -- (ab.center) -- (ab.corner 2) -- (b.corner 6) -- (b.center) -- (b.corner 5) -- cycle;
        \fill[bcolor!50!bccolor] (b.corner 4) -- (b.center) -- (b.corner 3) -- (bc.corner 1) -- (bc.center) -- (bc.corner 6) -- cycle;
        \fill[bccolor!50!ccolor] (bc.corner 5) -- (bc.center) -- (bc.corner 4) -- (c.corner 2) -- (c.center) -- (c.corner 1) -- cycle;
        \fill[ccolor!50!accolor] (c.corner 6) -- (c.center) -- (c.corner 5) -- (ac.corner 3) -- (ac.center) -- (ac.corner 2) -- cycle;
        \fill[accolor!50!acolor] (ac.corner 1) -- (ac.center) -- (ac.corner 6) -- (a.corner 4) -- (a.center) -- (a.corner 3) -- cycle;
    \end{pgfonlayer}
\end{tikzpicture}

\end{document}

所有集合均非空的结果

在此处输入图片描述

结果 ABC、A 和 BC 为空

\node[unvenn=abccolor] at (0,0) (abc) {$A\cap B\cap C$};
\node[unvenn=acolor] at (0:\nodescenterseparation) (a) {$A$};
\node[venn=abcolor] at (60:\nodescenterseparation) (ab) {$A\cap B$};
\node[venn=bcolor] at (120:\nodescenterseparation) (b) {$B$};
\node[venn=bccolor] at (180:\nodescenterseparation) (bc) {$B\cap C$};
\node[unvenn=ccolor] at (240:\nodescenterseparation) (c) {$C$};
\node[venn=accolor] at (300:\nodescenterseparation) (ac) {$A\cap C$};

在此处输入图片描述

相关内容