I put a couple of previous posts together
How can find the 2D Voronoi cell area distribution?
Color code Voronoi cell areas depending on number of vertices
color voronoi cell based on area
to make the below script, but honestly I do not know what is going on so I cannot change it properly. my questions:
Colouring the cells by their area; how can I improve the figure visually (increasing the contrast between the colors)? as you can see due to the larger cells the BarLegend and the colouring does not help that much to differentiate the cells which their areas are close. Is it possible to dismiss the cells which have larger area (say if area > sth ) and leave them as uncoloured (white) cells?
Another post shows how to colour the cells based on the number of vertices. How can I add BarLegend to this plot to highlight which colour corresponds to which number of vertices?
Is it possible to use Voronoi diagram for a number of points? I mean having for example 7 points in each cell rather than 1 point and apply the method. Probably one way is to replace the i.e. 7 points with their geometrical mean point manually and apply the Voronoi diagram, but I think for large number of data points it is not a good idea.
Thank you all for sharing your knowledge and expertise.
Here is my script:
d1 = ReadList["f1", {Number, Number}];
mesh0 = VoronoiMesh[d1, {-275, 275}, Axes -> True, PlotTheme -> "Lines"]
mesh = Graphics[{FaceForm[None], EdgeForm[Black],
MeshPrimitives[mesh0, {2, "Interior"}]}]
areas = PropertyValue[{mesh0, 2}, MeshCellMeasure];
MinMax[areas]
Legended[SetProperty[{mesh0, {2, All}},
MeshCellStyle -> ColorData["Rainbow"] /@ Rescale[areas]],
BarLegend[{"Rainbow", MinMax[areas]}]]
colorvm =
Map[{ColorData[97, First[Dimensions[First[#]]] - 2], #} &,
MeshPrimitives[mesh0, {2, "Interior"}]];
Legended[Graphics[{EdgeForm[Black], colorvm},
PlotRange -> {{-275, 275}, {-275, 275}}],
BarLegend["Rainbow", {3, 7}]]
You can find the data here enter link description here
Edit: After @J.M.'sennui's comment, here you can find the new images; colour by area and colour by vertices
VoronoiMesh[]
, and the second argument in particular? "I cannot find the link to upload my data" - go to pastebin.com, post your data there, and link to it here. $\endgroup$ – J. M.'s ennui♦ Jan 22 at 9:13