维恩图中 3 组圆圈的不同突出显示或填充方式

维恩图中 3 组圆圈的不同突出显示或填充方式

venndiagram包用于绘制三集维恩图。

我怎样才能用不同的阴影、线条、加号+等符号填充该图表的子集?

理想的命令界面可以是像\shade{\fillOnlyB}{white!85!black}示例中那样设置阴影或者\fill{\fillOnlyB}{+}{50}用加号填充50%图表的一部分。

禁止使用不同的颜色(灰色除外)。

MWE 如下:

    \documentclass[14pt]{memoir}

    % no INLIGNED opportunity to use RUSSIAN in arrows, see commented \draw commands
    %http://mirror.macomnet.net/pub/CTAN/macros/latex/contrib/venndiagram/venndiagram.pdf
    \usepackage{venndiagram}
    %rename circles
    \makeatletter
    %\renewcommand*{\@venn@label@A}{$Z$} 
    %\renewcommand*{\@venn@label@B}{$X$}    
    %\renewcommand*{\@venn@label@C}{$Y$}
    \renewcommand*{\@venn@label@A}{} 
    \renewcommand*{\@venn@label@B}{}    
    \renewcommand*{\@venn@label@C}{}
    \makeatother

    \makeatletter
    \renewcommand*{\@venn@shade}{white!85!black}
    \makeatother
    \begin{document}

    \begin{figure} 
        \begin{center}
            \resizebox{0.95\linewidth}{!}{
                %>{\columncolor[gray]{0.9}} % doesn't work with \rowcolor
                \begin{venndiagram3sets}[labelOnlyA={${\mathit{3}}$},labelOnlyB={${\mathit{1}}$},labelOnlyC={${\mathit{2}}$},
                    labelOnlyAB={${\mathit{4}}$},labelOnlyAC={${\mathit{6}}$},labelOnlyBC={${\mathit{5}}$},labelABC={${\mathit{7}}$},
                    labelNotABC={${\mathit{8}}$}]
                    \setpostvennhook
                    {
                        \draw[<-] (labelA) -- ++(135:3cm) node[above,align=left] {$Z$ };
                        \draw[<-] (labelB) -- ++(45:2.2cm) node[above,align=left] {$X$ };
                        \draw[<-] (labelC) -- ++(-45:3cm) node[right, align=left] {$Y$};
                        \draw[<-] (labelABC) -- ++(0:3cm)
                        node[right,text width=4.2cm,align=flush left, align=left] { ${\mathit{7}}$ };
                        \draw[shorten >=-1.7cm,shorten <=2.4cm,<-] (labelABC) -- ++(-180:2cm)
                        node[left,text width=2.6cm,align=flush left, align=left] { $U$ };
                        \draw[<-] (labelNotABC) -- ++(-100:1.2cm)
                        node[below,align=left] %,text width=5cm
                        {${\mathit{8}}$}; %
                    }
                    % the interface to fill circles or their parts
                    % \fillACapCNotB
                    % \fillOnlyB
                    \fillACapCNotB    
                \end{venndiagram3sets}
            }
        \end{center}
        \caption{Venn diagram with differently filled parts of circles}\label{fig-ViennDiagramm}
    \end{figure}

    \end{document}

在此处输入图片描述

答案1

在各种方面都不令人满意(并且可能是不可取的),但这里tikzpicture用一个命令进行修补,该命令修补了维恩图填充命令的子集(如果已定义),取消填充并允许将附加键传递给路径。

\documentclass[varwidth,border=5]{standalone}
\usepackage{venndiagram}
\usetikzlibrary{patterns}
\usepackage{etoolbox}
\makeatletter
\def\patchvenncmds#1{%
  \pgfutil@for\@cmd:={#1}\do{%
    \expandafter\ifpatchable\expandafter{\csname\@cmd\endcsname}{]}{%
    \expandafter\patchcmd\expandafter%
      {\csname\@cmd\endcsname}{]}{,.. this/.try]}{}{}%
    \pgfutil@namelet{\@cmd @orig}{\@cmd}%
    \expandafter\patchvenncmd\expandafter{\@cmd}}{}}}
\def\patchvenncmd#1{%
  \expandafter\renewcommand\csname#1\endcsname[1][]{%
    \tikzset{.. this/.style={fill=none,##1}}\csname#1@orig\endcsname}}
\makeatother
\preto\tikzpicture{\patchvenncmds{%
fillA,fillB,fillC,fillAll,fillNotA,fillNotB,fillNotC,% <- % is important
fillNotA,fillNotB,fillNotC,fillNotABC,fillOnlyA,fillOnlyB,fillOnlyC,%
fillACapCNotB,fillBCapCNotA% ...etc
}}{}{}  
\begin{document}
\begin{venndiagram3sets}[
  labelOnlyA=$3$,labelOnlyB=$1$,labelOnlyC=$2$,labelOnlyAB=$4$,
  labelOnlyAC=$6$,labelOnlyBC=$5$,labelABC=$7$,labelNotABC=$8$]              
\fillACapCNotB[pattern=north east lines]
\fillA[pattern=north west lines]
\fillBCapCNotA[pattern=crosshatch dots]
\fillNotABC[pattern=dots]
\end{venndiagram3sets}
\end{document}

在此处输入图片描述

相关内容