# Voronoi Visualization

**URL:** <https://discourse.julialang.org/t/voronoi-visualization/36602>\
**Category:** Visualization\
**Created:** [March 27, 2020, 2:53pm UTC](https://discourse.julialang.org/t/voronoi-visualization/36602 "2020-03-27T14:53:21Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [April 1, 2020, 11:03am UTC](https://discourse.julialang.org/t/voronoi-visualization/36602/14 "2020-04-01T11:03:41Z")

</div>

OK, painting the polygons uncovered an issue in the GMT.jl wrapper and a feature in the GMT program `triangulate` itself. So I have to resort to the hard core GMT syntax to show it. The issue is how to color the polygons with a colormap. Next version of GMT has a more handy way of assigning colors to polygons. But for now, this works and will be made nicer to read when I fix the wrapper issue.

```julia
D,G = triangulate("lixo.csv", region=(0,10,0,10), voronoi="n", grid=true, inc=0.05, network=true, edges=true);
triangulate [WARNING]: -Qn is experimental and unstable.

C = makecpt(cmap=:categorical, range=(0,10,1), cptname="categorical.cpt");
plot("-JX12c/0 -Baf -BWSen -Ccategorical.cpt -R-0.4/10.4/-0.4/10.4 -W1p+cf -P > voro_color.ps", D)

```

 ![voro_color](https://global.discourse-cdn.com/julialang/original/3X/4/2/429819c2e3a7589462c46f44cee69bd941d30e07.png)

OK, for the record. The [GMT.jl](https://github.com/GenericMappingTools/GMT.jl) issue was just an harmless wrong warning and the GMT feature was actually my lack of attention reading the manual. The image above (and with the file posted at the beginning of this thread) can be obtained with

```julia
using GMT
D = triangulate("lixo.csv", region=(0,10,0,10), voronoi="n", network=true, xyz=true);
triangulate [WARNING]: -Qn is experimental and unstable.

C = makecpt(cmap=:categorical, range=(0,10,1));
plot(D, color=C, aspect=:equal, show=true, pen=(lw=1, csymbol=true), savefig="voronoi_colored.png")

```

---

_[View the full topic](https://discourse.julialang.org/t/voronoi-visualization/36602)._
