Is it possible to plot a two-set/disc Venn diagram with proportional discs and intersection without having to use the below "trial-and-error" code? In the example below the left disc has 6 elements (disc area = 6), the right disc has 4 elements (disc area = 4) and the intersection has 2 elements (area = 2)

a1 = 6;
a2 = 4;
a1capa2 = 2;
d = 1.21;
y1[x_] := Sqrt[a1/π - x^2]
y2[x_] := Sqrt[a2/π - (x - d)^2]
    {y1[x], -y1[x], y2[x], -y2[x]}, {x, -2, 4},
    AspectRatio -> Automatic, PlotStyle -> {Black}
x0 = x /. Solve[y1[x] == y2[x], x][[1]]
caparea = 2 (N[Integrate[y2[x], {x, d - Sqrt[a2/π], x0}]] +
    N[Integrate[y1[x], {x, x0, Sqrt[a1/π]}]]

Here I have to guess the distance $d$ between the discs in order to get the intersection area, caparea, to the requested 2. (It also give an imaginary reply, which I find odd.)

enter image description here

I'm looking for a solution where you only input the disc areas, and the intersection area and the distance $d$ is calculated and the graph plotted.

There are several other solutions for Venn diagrams but they all seem to have the same disc size.



You could use Region functionality instead. Your disks:

d1 = Disk[{0,0}, Sqrt[6/π]];
d2 = Disk[{d,0}, Sqrt[4/π]];

The intersection area:

area = Assuming[1 < d < 2, Area @ RegionIntersection[d1, d2]];
area //TeXForm

$\frac{-8 \sin ^{-1}\left(\frac{\pi d^2-2}{4 \sqrt{\pi } d}\right)+12 \sec ^{-1}\left(\frac{2 \sqrt{6 \pi } d}{\pi d^2+2}\right)-\sqrt{-\pi ^2 d^4+20 \pi d^2-4}+4 \pi }{2 \pi }$

Solving to find d:

sol = d /. First @ NSolve[area == 2 && 1 < d < 2, d]



Block[{d = sol},
    Graphics[{FaceForm[None], EdgeForm[Black], d1, d2}, Axes->True]

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.