| netmap | R Documentation |
network and igraph objects on a sf map
using ggplot2The netmap package extends the ggnetwork package by providing functions to
plot networks, with vertices usually representing objects with a spatial
attribute (cities, regions, countries, users with location data attached etc.)
on a map, provided by a sf object (which in turn is able to represent
more or less all spatial data available). Networks and maps need not have the
same set of elements: if they don't, only the intersection will be represented.
The main function is ggnetmap, which produces a data.frame
that is then used as data within ggplot2 calls. For those wishing
to use the plot.network or the
plot.igraph function to plot the network
(without overlaying it on an sf object), both a custom layout function,
network.layout.extract_coordinates, and a wrapper that provides
convenient manipulation of network and sf objects,
netmap_plot, are available.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.