Timothée Giraud



The aim of mapsf is to obtain thematic maps with the visual quality of those build with a classical mapping or GIS software.

Users of the package could belong to one of two categories: cartographers willing to use R or R users willing to create maps. Therefore, its functions have to be intuitive to cartographers and ensure compatibility with common R workflows.

mapsf uses sf objects to produce base graphics.

mapsf functions can be classified in the following categories :

Main Features


The type column indicates the value to use for the type argument in mf_map(x, var, type). The data column displays the relevant data types for each map types. The cartography column indicates the corresponding function in cartography.

map type type data polygon point line cartography
Base Map "base" geometry -
Proportional Symbols "prop" stock propSymbolsLayer()
Typology "typo" category typoLayer()
Choropleth "choro" ratio choroLayer()
Graduated Symbols "grad" stock -
Symbols "symb" category -
Proportional Symbols + Typo "prop_typo" stock & category propSymbolsTypoLayer()
Proportional Symbols + Choro "prop_choro" stock & ratio propSymbolsChoroLayer()
Symbols + Choro "symb_choro" category & ratio -

Map Layout

name cartography
mf_title() - / layoutLayer()
mf_arrow() north()
mf_credits() - / layoutLayer()
mf_scale() barscale()
mf_layout() layoutLayer()
mf_annotation() -
mf_label() labelLayer()


mf_theme() defines a map theme. It sets the margins of the figure, a background color, a foreground color and some parameters of the title. A set of theme is included in the package and it is possible to create custom ones.


The mf_export() function exports maps in raster (.png) or vector formats (.svg). The size of the exported map will fit the height/width ratio of a spatial object.


Several datasets are embedded in the package:

Examples of thematic maps

Base map

mf_init() is designed to initiate a map centered on a specific extent (x bbox). The theme argument allows to select a theme.

mf_shadow() plots the shadow of a polygon layer.

mf_map(x, type = "base") displays sf objects geometries.

mf_layout() add a complete layout to the map (title, credits, north arrow, scale bar). Each layout elements can also be set separately (with mf_title(), mf_credits(), mf_arrow() and mf_scale()).

Proportional Symbols

mf_map(x, var, type = "prop") displays symbols with areas proportional to a quantitative variable (stocks). The inches argument is used to customize the symbols sizes.

Choropleth Map

In choropleth maps, areas are shaded according to the variation of a quantitative variable. They are used to represent ratios or indices.
mf_map(x, var, type = "choro") displays choropleth maps . Arguments nbreaks, and breaks allow to customize the variable classification. mf_get_breaks() allows to classify data outside of the function itself. Colors palettes, defined with pal, can be created with mf_get_pal() or you can use palette names from hcl.pals().

Use mf_theme() to set a theme without plotting anything.

Typology Map

mf_map(x, var, type = "typo") displays a typology map of a qualitative variable. val_order is used to set the modalities order in the legend.

mf_label() displays labels on the map.

Proportional Symbols using Choropleth Coloration

mf_map(x, var, type = "prop_choro") creates a map of symbols that are proportional to values of a first variable and colored to reflect the classification of a second variable.

expandBB argument in mf_init() allows to expand the map space. Here, we increase the space available on the right of the map to avoid overlaps between the legends and the map.

Proportional Symbols using Typology Coloration

f_map(x, var, type = "prop_typo") creates a map of symbols that are proportional to values of a first variable and colored to reflect the modalities of a second qualitative variable.

Label Map

mf_label() is dedicated to the display of labels on a map. The overlap = FALSE argument displays non overlapping labels.

In this example we have built a custom theme with mf_theme().