维恩图,相对其内容的大小

维恩图,相对其内容的大小

现在,我正在寻找是否有任何简单的方法来创建维恩图,其中圆圈/椭圆相对于其内容改变大小。我基本上在寻找简单的赞美,无论是在形式上

[\img]https://i.stack.imgur.com/8Irn9.gif[img]或包含三个元素

我正在寻找的输出有点类似 在此处输入图片描述

圆圈的大小与其百分比或概率有关。(圆圈越大,概率越大),最大的圆圈代表 1 或 100%

现在是否可以创建一个宏来创建这样的图像?例如,假设 A=40 , B=60 , A \cap B = 20

答案1

答案是“不可能”。您无法绘制具有所要求值的圆: A=.40 , B=.60 , A \cap B = .20 ,如 R. Schumacher 所写。

在此处输入图片描述

\documentclass[11pt]{scrartcl} 
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{tikz,verbatim}
\usetikzlibrary{arrows,patterns}

\begin{document}

\begin{tikzpicture}[scale=4,>=latex']
  \draw[magenta] circle[radius=1cm]; 
  \node[above right,magenta] at (0,1) {$\mathcal{C}$};  
  \draw (0.63245-1,0) circle [radius=0.63245cm];   % sqrt(0.4) 
  \draw (1-0.77459,0) circle [radius=0.77459cm];   % sqrt(0.6)
  \node[above right] at (-1,0) {$\mathcal{C}_a$};
  \node[above left] at ( 1,0) {$\mathcal{C}_b$};
  \draw[->] (-1,0)--(1.2,0); 
  \draw[->] (0,-1)--(0,1.2);
  \filldraw[blue] (0.63245-1,0) circle(.4pt) -- node[above right]{$ra\approx 0.632$}++(60:0.63245); 
  \filldraw[blue] (1-0.77459,0) circle(.4pt) -- node[above right]{$rb\approx 0.774$}++(60:0.77459);
    \draw[magenta,<->] (0,0) -- node[below]{1} (1,0);  
   \clip (0.63245-1,0) circle [radius=0.63245cm];   % sqrt(0.4) 
   \clip (1-0.77459,0) circle [radius=0.77459cm];   % sqrt(0.6)
   \fill[pattern=north east lines,fill opacity=.5]  circle[radius=1cm];
   \draw[red,<->] (0.63245-1,-0.05) -- node[below]{0.59296} (1-0.77459,-0.05);

   \node at (-0.25,-0.4){$\mathcal{A}$};     
\end{tikzpicture}

\begin{verbatim}
Macro to determine the area of the asymmetric lens.
\pgfmathsetmacro{\ra}{sqrt(0.4)} 
\pgfmathsetmacro{\rb}{sqrt(0.6)}
\pgfmathsetmacro{\d}{2-0.63245-0.77459}    
\pgfmathsetmacro{\area}{%
   (  \ra*\ra*acos((\d*\d-\rb*\rb+\ra*\ra)/(2*\d*\ra))/180*3.1415     
     +\rb*\rb*acos((\d*\d+\rb*\rb-\ra*\ra)/(2*\d*\rb))/180*3.1415
     -0.5*sqrt((-\d+\ra+\rb)*(\d+\ra-\rb)*(\d-\ra+\rb)*(\d+\ra+\rb))
     )/3.1415}  
\end{verbatim} 

\pgfmathsetmacro{\d}{2-0.63245-0.77459} 
\pgfmathsetmacro{\ra}{sqrt(0.4)} 
\pgfmathsetmacro{\rb}{sqrt(0.6)}   
\pgfmathsetmacro{\area}{%
   (  \ra*\ra*acos((\d*\d-\rb*\rb+\ra*\ra)/(2*\d*\ra))/180*3.1415     
     +\rb*\rb*acos((\d*\d+\rb*\rb-\ra*\ra)/(2*\d*\rb))/180*3.1415
     -0.5*sqrt((-\d+\ra+\rb)*(\d+\ra-\rb)*(\d-\ra+\rb)*(\d+\ra+\rb))
     )/3.1415}  

The area of the circle $\mathcal{C}$  is $1\times \pi$.

The area of the circle $\mathcal{C}_a$  is $0.4\times \pi$.

The area of the circle $\mathcal{C}_b$  is $0.6\times \pi$.   

If $d=0.59296$  then $\mathcal{A}=\area\times \pi$.


\pgfmathsetmacro{\d}{0.681}
\pgfmathsetmacro{\area}{%
   (  \ra*\ra*acos((\d*\d-\rb*\rb+\ra*\ra)/(2*\d*\ra))/180*3.1415     
     +\rb*\rb*acos((\d*\d+\rb*\rb-\ra*\ra)/(2*\d*\rb))/180*3.1415
     -0.5*sqrt((-\d+\ra+\rb)*(\d+\ra-\rb)*(\d-\ra+\rb)*(\d+\ra+\rb))
     )/3.1415} 

If $d=0.681$  then $\mathcal{A}=\area\times \pi$ but  $0.59296$  is the maximum value of $d$, so it's impossible to draw circles with the requested values.

\end{document}   

对于其他值,可以通过嵌套间隔(二分法)使用迭代方法。我发现0.681采用手动方法,但我认为构建一个算法来找到这个值并不困难。

相关内容