# Venn 5 diagram

Posted 2 years ago
3859 Views
|
|
9 Total Likes
|
 Code for a nice Venn 5. pp=RootReduce[2CirclePoints/(EuclideanDistance@@CirclePoints[[{1,2}]])]; sp=Join[Table[2.12CirclePoints[[Mod[n-2,10,1]]]+pp[],{n,1,9}], Table[1.05CirclePoints[[Mod[n-6,10,1]]]+pp[],{n,1,7}]]; Graphics[{AbsoluteThickness,Table[BSplineCurve[sp.RotationMatrix[2 k Pi/5], SplineClosed-> True],{k,0,4}]},ImageSize->600] Answer
 Hey Ed, I wanted to color your figure such that color classes correspond to the number of intersecting sets. The below code works (for any set of closed curves), however, it uses meshes which feels imprecise. Even for the 3 circle case one can see mesh artifacts. Whats the most natural way to do this? Would you generate the bounding (piecewise) curve for each region and assemble the figure that way, like a tiling? (*recreate booleanregion(buggy). zo_list is a 0,1 list (or list of \ lists) of region indicators*) booregion[regs_List, zo_List] := ( If [Depth[zo] == 2, If[Total[zo] == Length[zo], out = EmptyRegion, out = RegionUnion[Pick[regs, zo, 0]]]; RegionDifference[RegionIntersection[Pick[regs, zo, 1]], out], RegionUnion[booregion[regs, #] & /@ zo] ] ) (*generate weight k binary vectors of length n*) class[n_Integer, k_Integer] := ReplacePart[ConstantArray[0, n], Thread[# -> 1]] & /@ Subsets[Range[n], {k}] vennplot[regs_List, colors_List] := ( len = Length[regs]; Graphics@ Riffle[colors[[;; len]], Table[booregion[regs, class[len, i]], {i, 1, len}]]) (*sp is defined in the original post*) regs = Table[ DiscretizeGraphics[ FilledCurve@ BSplineCurve[sp.RotationMatrix[2 k Pi/5], SplineClosed -> True]], {k, 0, 4}]; vennplot[regs, ColorData["TemperatureMap"] /@ Range[0, 1, .25]]  Answer