This section is dedicated to maps on which we add markers. These markers can be bubble with a size relative to a numeric value: in this case we call it a bubble map. If you need to make an interactive map

I advise to use the leaflet library that has specific functions to easily map shapes to values. Concerning static maps, several tools exist and once more, ggplot2 shows to be a very good option. Once your

basemap is made, you can use whatever geom() like if it was a normal plot. However, not that the cartography library can also be a very good possibility.

 

Sponsors


 

Interactive map with marker: use leaflet


Once more, the leaflet library is probably your best option to make an interactive map with markers. It allows you to add any type of annotation and your map, and provide a message when the user click the marker. The examples below should teach you how to add dots, bubble, rectangles and more!

Here is the kind of interactive version you can get (try to zoom and hover):

Graph #19: bubble map with leaflet (code)

 

Static map with marker: use ggplot2


You can use all the power of ggplot2 to make scatter plots, bubbles chart, add annotation or whatever else on a background map!

 

 

 

 

Interactive bubble map with ggplotly


 

 

 

 

 

If you’ve decided to work with ggplot2, plotly allows to quickly get an interactive version of your map (2 more lines of code only!). This is really handy since it allows to zoom on the map and hover a city to know its name and population!

 

Other option: the cartography library


The cartography library allows to make some very nice looking bubble maps. Check it out.

 

 

Related


Search the gallery