Is it possible to color the scipy.spatial.Voronoi
diagram? I know it is.
But now my goal is to color each cell according to a color scale to represent a physical quantity.
As in the image below (PRL 107, 155704 (2011)):
And I would also like to know if it is possible to calculate the area of each cell, because it is a quantity that I would like to calculate
Color scale:
Actually the link you provide gives the code needed to colorize the Voronoi diagram. In order to assign each cell a color representing a physical quantity, you need to map the values of this physical quantity to a normalized colormap using the method shown in Map values to colors in matplotlib.
For example, if I want to assign each cell a color corresponding to a quantity 'speed':
Sample output:
)
Area of cells:
scipy.spatial.Voronoi
allows you to access the vertices of each cell, which you can order and apply the shoelace formula. I haven't tested the outputs enough to know if the vertices given by the Voronoi algorithm come already ordered. But if not, you can use the dot product to get the angles between the vector to each vertex and some reference vector, and then order the vertices using these angles: