# Three ways of visualizing a graph on a map and more aRticles

In this blog post, I’ll present 3 ways of visualizing network graphs on a map using R with the packages igraph, ggplot2 and optionally ggraph. Several houses of our graph should be visualized together with the positions on the map and the connections between them. Specifically, the dimensions of a node on the map should replicate its degree, the width of an edge among two nodes should constitute the burden power of this connection since we cannot use proximity to illustrate the energy of a connection once we place the nodes on a map, and the color of an edge should illustrate the kind of connection some express variable, e. g. a type of treaty among two foreign companions.

Let’s start simple through the use of ggplot2. We’ll need three geometric objects geoms extra to the country polygons from the world map country shapes: Nodes can be drawn as points using geom point and their labels with geom text; edges among nodes can be realized as curves using geom curve. For each geom we need to define aesthetic mappings that “describe how variables in the info are mapped to visual houses” in the plot. For the edges, we pass our edges for plot data frame and use the x, y and xend, yend as start and end points of the curves. Additionally, we make each edge’s color based on its class, and its “size” which refers to its line width dependent on the edges’ weights we will see that the latter will fail.

Note that the order of the geoms is essential as it defines which object is drawn first and can be occluded by an object it truly is drawn later in the next geom layer. Hence we draw the perimeters first and then the node points and at last the labels on top:The Tidytext package extends the tidy data philosophy to a text. In this approach to text analysis, a corpus consists of a data frame where each word is a separate item. The code snippet below takes the 1st 72 rows and the unnest tokens function extracts each word from the 72 definitions. This function can also extract ngrams and other word groups from the text.