# Plot Map in Julia

**URL:** <https://discourse.julialang.org/t/plot-map-in-julia/84019>\
**Category:** General Usage\
**Tags:** plotting, map\
**Created:** [July 10, 2022, 12:39pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019 "2022-07-10T12:39:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [July 10, 2022, 12:39pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/1 "2022-07-10T12:39:00Z")

</div>

Hi all,

I want to know is it possible to plot map with color for different country by using Julia. like this:

 ![Capture d’écran_2022-07-10_19-25-03](https://global.discourse-cdn.com/julialang/original/3X/9/d/9d070aa3b4952ddbf868452840bf57bc2df2413b.png)

Each color could represent certain cluster/grouping.

I see mapbox is expensive, we need to have credit cards just for registration. Some like me do not have such luxury.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [July 10, 2022, 1:13pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/2 "2022-07-10T13:13:59Z")

</div>

A quick search (on my phone) in this discourse led me to

> <https://gist.github.com/TheCedarPrince/52f9be6c14479fecce0b403751fafcc2>

but there are also resources such as Makie, GMT, OpenStreeMapX, to name a few.

Perhaps you could try a few and post your code if you get stuck?

---

<div class="post-metadata">

**Author:** ![josuagrw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josuagrw/32/1015_2.png) [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Post date:** [July 10, 2022, 1:37pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/3 "2022-07-10T13:37:44Z")

</div>

You could find a free SVG map and then manipulate the colors using [GitHub - JuliaIO/LightXML.jl: A light-weight Julia package for XML based on libxml2.](https://github.com/JuliaIO/LightXML.jl)

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [July 10, 2022, 1:52pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/4 "2022-07-10T13:52:06Z")

</div>

If you want to plot a mapbox choropleth, you don’t have to pay for mapbox, when callling `PotlyJS.choroplethmapox`.  
See an example here [https://discourse.julialang.org/t/valid-geojson-object-for-choroplethmapbox-trace/72592](https://discourse.julialang.org/t/valid-geojson-object-for-choroplethmapbox-trace/72592)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 10, 2022, 5:04pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/5 "2022-07-10T17:04:29Z")

</div>

Linking a [related thread](https://discourse.julialang.org/t/how-do-i-add-a-colorbar-to-a-choropleth-map/57814/5).

---

<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:** [July 10, 2022, 8:17pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/6 "2022-07-10T20:17:22Z")

</div>

The problem is not to make the choropleth map (here’s another [elaborated example](https://www.generic-mapping-tools.org/GMTjl_doc/tutorials/dlakelan/GMTMaps/) in GMT.jl  
The problem is on how to plot the country names without doing it one by one.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 10, 2022, 8:36pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/7 "2022-07-10T20:36:35Z")

</div>

> [@joa-quim](#):
>
> The problem is on how to plot the country names without doing it one by one.

Simply load a CSV with country centre coordinates as [shown here](https://developers.google.com/public-data/docs/canonical/countries_csv).

---

<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:** [July 10, 2022, 8:43pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/8 "2022-07-10T20:43:07Z")

</div>

Not that simple. Those simple cases could be automatically set by computing the country polygon’s centroids. The real problem comes from cases like (using the example fig)  
Democratic Republic of Congo  
Tunisia  
Burundi  
Djibouti  
Lesotho

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 10, 2022, 8:46pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/9 "2022-07-10T20:46:40Z")

</div>

Well, if you have less than 10 country names then adjusting the position of the labels manually should be easy…

---

<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:** [July 10, 2022, 11:08pm UTC](https://discourse.julialang.org/t/plot-map-in-julia/84019/10 "2022-07-10T23:08:41Z")

</div>

Good luck with 🙂

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/5/f5f7a8f68a8531602afb0cf17abd8fee00e50be1.jpeg)
