复杂维恩图

复杂维恩图

针对我的问题维恩图重叠颜色填充,我有以下 MWE:

\documentclass{book}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,fadings,patterns}
\begin{document}
\begin{figure}[h]\centering
\pagestyle{empty}
\def\firstcircle{(0,0) circle (2.0cm)}
\def\secondcircle{(360:3.5cm) circle (2.0cm)}
\begin{tikzpicture}
\begin{scope}
    \fill[style=shade, top color=white, bottom color=brown!80!black!20][black] \firstcircle;
    \fill[style=shade, top color=white, bottom color=cyan!80!black!20 ][black] \secondcircle;
    \draw \firstcircle node{\textsc{Rules-Based (Passive)}};
    \draw \secondcircle node{\textsc{Bet Against Market Portfolio (Active)}};
     \clip \firstcircle;
  \fill[red][fill opacity=0.6]\secondcircle;
\end{scope}
\end{tikzpicture}
\end{figure}
\end{document}

但是,我想实现的不是输出(下图),而是包含圆圈并能处理较长文本的维恩图;类似于此(上图为蓝色和紫色)​​:如何实现呢?双维恩图

答案1

使用 TikZ v. 3.0.0 中的新混合模式功能可以实现(请参阅TikZ/pgf 3.0 有哪些新功能?)这样可以避免使用某些剪辑操作:

\documentclass[tikz,border=10pt]{standalone}

\begin{document}
\def\firstcircle{(0,0) circle (3.0cm)}
\def\secondcircle{(360:3.5cm) circle (3.0cm)}
\begin{tikzpicture}[blend group=screen]
\begin{scope}[fill opacity=0.3,text opacity=1,white,align=center,text width=2.5cm]
    \draw[fill=blue!50!cyan!60!black] \firstcircle 
    node[shift={(-.75,1)},text=blue!50!cyan!60!black]{\textsc{Rules-Based (Passive)}};
    \draw[fill=violet!60!red] \secondcircle 
    node[shift={(.75,1)},text=violet!60!red]{\textsc{Bet Against Market Portfolio (Active)}};
    \node[text=white] at (1.65,0){\textsc{Strategic Beta}};
    \begin{scope}[scale=0.8,transform shape,align=center,white,fill opacity=1]% little circles
    \draw[fill=blue!50!cyan!60!black](-0.5,-1.25)circle(1.45cm) 
     node[text width=2.25cm,text=white] {\textsc{Market-Cap\\ Weighted}};

     \draw[fill=violet!60!red](6,-1.25)circle(1.35cm) 
     node[text width=2.25cm,text=white] {\textsc{Actively\\ Managed}};
    \end{scope}
\end{scope}
\end{tikzpicture}

\end{document}

结果:

在此处输入图片描述

答案2

你也可以用普通的方式绘制此类图表元帖子,使用内置的颜色算法。

在此处输入图片描述 颜色可以被认为是(r,g,b)3 元组,但你可以将它们作为向量进行加、减和缩放。普通 MP 定义

  • red作为(1,0,0)
  • green作为(0,1,0)
  • blue作为(0,0,1)
  • white作为(1,1,1)

>1被视为1用于制作颜色。将两种颜色相加,然后相减white,使每种成分回到 0 到 1 的范围内,通常可以得到很好的混合。

prologues := 3;
outputtemplate := "%j%c.eps";
verbatimtex
\let\\=\cr
\font\sc=phvr8r
\def\stack#1{$\vcenter{\halign{\sc{##}\hfil\cr#1\crcr}}$}
etex
beginfig(1);

u = 8mm;

path a[];
a1 = fullcircle scaled 9u shifted (3u,0);
a2 = fullcircle scaled 9u shifted (-3u,0);
a3 = fullcircle scaled 3u shifted (4u,-2u);
a4 = fullcircle scaled 3u shifted (-2u,-2u);
a5 = buildcycle(subpath(-2,2) of a2, a1);
a6 = buildcycle(subpath(-2,2) of a4, a1);

color filler[];
filler1 = .2 red  + .1 blue  + .7 white; 
filler2 = .2 blue + .1 green + .7 white;
filler3 = .6 red + .3 blue;
filler4 = .55 blue + .35 green;
filler5 = filler1+filler2-white;
filler6 = filler1+filler4-white;

for i=1 upto 6: fill a[i] withcolor filler[i]; endfor
for i=1 upto 4: draw a[i] withpen pencircle scaled 0.2 withcolor white; endfor

label(btex \stack{Bet Against\\
              Market Portfolio\\(Active)} etex scaled 1.4, center a1 shifted (+2/3u,2u)) withcolor .5 red + .05 blue;
label(btex \stack{Rules-Based\\(Passive)} etex scaled 1.4, center a2 shifted (-2/3u,2u)) withcolor .1 green + .35 blue + .1 white;
label(btex \stack{Actively\\Managed}      etex, center a3) withcolor white;
label(btex \stack{Market-Cap\\Weighted}   etex, center a4) withcolor white;
label(btex \stack{Strategic\\Beta}        etex, center a5) withcolor white;  

endfig;
end.

答案3

这可能包含一个提示:

\begin{tikzpicture}[every node/.style={font=\small}]
\begin{scope}
  \node[draw,circle,minimum width=3cm,fill,style=shade, top color=white, bottom color=brown!80!black!20] (one) at (0,0) {};
  \node[below,align=left, text width=1.5cm] at ($(one.north)+(0,-.5)$) {This is a random text};
  \node[draw,circle,minimum width=3cm,fill,style=shade, top color=white, bottom color=green!80!black!20] (two) at (2,0) {};
  \node[below,align=left, text width=1.5cm] at ($(two.north)+(.5,-.5)$) {This is a random text};
  \clip (0,0) circle (1.5cm);
  \fill[red,fill opacity=0.6] (2,0) circle (1.5cm);
\end{scope}
\end{tikzpicture}

calc除了 之外,您还需要tikzlibrary shapes,fadings,patterns

相关内容