Venn 5 diagram - Online Technical Discussion Groups—Wolfram Community (original) (raw)
Message Boards
6
|
8341 Views
|
1 Reply
|
9 Total Likes
Code for a nice Venn 5. pp=RootReduce[2CirclePoints[5]/(EuclideanDistance@@CirclePoints[5][[{1,2}]])]; sp=Join[Table[2.12CirclePoints[10][[Mod[n-2,10,1]]]+pp[[2]],{n,1,9}], Table[1.05CirclePoints[10][[Mod[n-6,10,1]]]+pp[[4]],{n,1,7}]]; Graphics[{AbsoluteThickness[2],Table[BSplineCurve[sp.RotationMatrix[2 k Pi/5], SplineClosed-> True],{k,0,4}]},ImageSize->600] |
---|
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[2], 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]] |
---|
Reply to this discussion in reply to
Attachments
Remove Add a file to this post