Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
I rewrote the code published in http://mathworld.wolfram.com/VennDiagram.html to work with the latest version of Mathematica.
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