# Coloring Voronoi cells in Delaunay Triangulations by area

I have a set of points which I have used the DelaunayTriangulation Package to generate voronoi cells. I have calculated the are of each cell, and now I want to color each cell according to the area. When I read the voronoiplot() documentation I know I can pass a color argument using `color=`, and I know DelaunayTriangulation uses CairoMakie. Can I just manually make a list of colors normalized by each cells area and pass that in? I don’t think I am constructing my color argument correctly!

I know I can also use the voronoicells package, but I want to clip my tessellations to the convex hull so DelaunayTriangulation is the best package for me!

Suppose that the voronoi diagram has n polygons and you have computed their area (here as a vector). If you saved areas in a different container, then you should adapt the following lines of code
To compare visually the area of polygons, it is recommended to use a colorscheme, not an arbitrary collection of colors.

``````area =2.5 .+3.2*rand(15)
amax, amin=extrema(area)
cs=ColorSchemes.haline
polygon_colors = [get(cs, (a-amin)/(amax-amin)) for a in area]
``````

I expect that `voronoiplot` can use these colors for your polygons.
I haven’t installed Makie to ckeck how `voronoiplot` works.

1 Like

Ok this is what I was looking for! I calculated the areas and then performed an inverse normal transform on them so that the values could easily be used for a colorscale…Ill try this out and let you know how it goes

I believe you can also pass `:extrema` to `get` to simplify a bit, e.g.

``````using DelaunayTriangulation, CairoMakie, ColorSchemes
tri = triangulate_rectangle(0, 1, 0, 1, 10, 10)
vorn = voronoi(tri, true)
areas = get_area.(Ref(vorn), 1:num_polygons(vorn))