Created
December 23, 2017 13:58
-
-
Save taroyabuki/5d54e56965ef9d58c4018eb27d2db75d to your computer and use it in GitHub Desktop.
I rewrote the code published in http://mathworld.wolfram.com/VennDiagram.html to work with the latest version of Mathematica.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VennDiagram[n_, ineqs_: {}] := Module[{i, r = .6, R = 1, v, x, y, f}, | |
v = Table[Circle[r {Cos[#], Sin[#]} &[2 Pi (i - 1)/n], R], {i, n}]; | |
{ | |
If[ineqs == {}, {}, | |
f = And @@ (v /. Circle[{xx_, yy_}, rr_] :> (x - xx)^2 + (y - yy)^2 < rr^2)[[ineqs]]; | |
RegionPlot[ImplicitRegion[f, | |
{x, y}], Axes -> False, | |
DisplayFunction -> Identity][[1]] | |
], | |
v | |
} | |
] | |
Show[GraphicsGrid[ | |
Partition[ | |
Graphics[VennDiagram[2, #], PlotRange -> All, | |
AspectRatio -> Automatic, | |
PlotLabel -> TraditionalForm[And @@ (Subscript[A, #] & /@ #)] /. | |
True -> \[EmptySet]] & /@ Sort@Subsets[Range[2]], 2] | |
]] | |
Show[GraphicsGrid[ | |
Partition[ | |
Graphics[VennDiagram[3, #], PlotRange -> All, | |
AspectRatio -> Automatic, | |
PlotLabel -> | |
TraditionalForm[And @@ (Subscript[A, #] & /@ #)] /. | |
True -> \[EmptySet]] & /@ Sort@Subsets[Range[3]], 4] | |
]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment