In the
first part :
- network visualization: why? how?
- visualization parameters
- best practices - aesthetics and performance
- data formats and preparation
- description of the data sets used in the examples
- getting started with igraph
In the
second part : colors and fonts in graphs R.
In this part: parameters of graphs, vertices and edges.
Network Plotting
Building with igraph: network graphics have an extensive set of options. In particular, there are vertex settings (start with
vertex.
) And edge settings (start with
edge.
). Some of the settings are listed below, and more information can be obtained by running the
?igraph.plotting
.
Build options in igraph (among others):
')
Vertices
vertex.color | vertex color |
vertex.frame.color | vertex outline color |
vertex.shape | vertex designation form, one of the values ​​“none”, “circle”, “square”, “csquare”, “rectangle”, “crectangle”, “vrectangle”, “pie”, “raster”, “sphere” |
vertex.size | vertex size (default is 15) |
vertex.size2 | second parameter of vertex size (for example, for a rectangle) |
vertex.label | vector of symbols for vertices |
vertex.label.family | font family for vertex labels (for example, Times, Helvetica) |
vertex.label.font | font: 1 - regular, 2 - bold, 3 - italic, 4 - bold italic, 5 - character |
vertex.label.cex | font size (multiplier, device dependent) |
vertex.label.dist | the distance between the mark and the top |
vertex.label.degree | location of the label in relation to the vertex: 0 - on the right, "pi" - on the left, "pi / 2" - on the bottom, "-pi / 2" - on the top |
Ribs
edge.color | edge color |
edge.width | edge width default 1 |
edge.arrow.size | default arrow size 1 |
edge.arrow.width | arrow width, default 1 |
edge.lty | line type, either 0 or “blank”, 1 or “solid”, 2 or “dashed” (discontinuous), 3 or “dotted” (dash), 4 or “dotdash” (dot-dash) ), 5 or “longdash” (long dash), 6 or “twodash” (double dash) |
edge.label | edge symbol vector |
edge.label.family | font family for edge labels (for example, Times, Helvetica) |
edge.label.font | font: 1 - regular, 2 - bold, 3 - italic, 4 - bold italic, 5 - character |
edge.label.cex | font size of edge marks |
edge.curved | rib bend, in the range from 0 to 1 (FALSE sets to 0, TRUE to 0.5) |
arrow.mode | a vector that determines whether the edges should have arrows, possible values: 0 - no arrows, 1 - reverse, 2 - straight, 3 - in both directions |
Other
margin | empty borders around the graph, vector of length 4 |
frame | if TRUE, the graph will be framed |
main | if set, adds a caption to the graphic |
sub | if set, adds a subtitle to the graphic |
Settings for vertices and edges can be set in two ways. The first is to set them using the
plot()
function, as shown below.
# (edge.curved=.1) : plot(net, edge.arrow.size=.4, edge.curved=.1)

# # , "media" plot(net, edge.arrow.size=.2, edge.color="orange", vertex.color="orange", vertex.frame.color="#ffffff", vertex.label=V(net)$media, vertex.label.color="black")

Another way to set attributes is to add them to the igraph object. Let's say we want the color of the vertices of the network to depend on the media, and the size depends on the degree of centrality (more links - more vertices). We will also change the width of the ribs depending on their weight.
# : colrs <- c("gray50", "tomato", "gold") V(net)$color <- colrs[V(net)$media.type] # ( ) : deg <- degree(net, mode="all") V(net)$size <- deg*3 # : V(net)$size <- V(net)$audience.size*0.6 # - . # NA, : V(net)$label <- NA # : E(net)$width <- E(net)$weight/6 # : E(net)$arrow.size <- .2 E(net)$edge.color <- "gray80" E(net)$width <- 1+E(net)$weight/12 plot(net)

You can also override attributes directly in the graphic:
plot(net, edge.color="orange", vertex.color="gray50")

It is useful to add a legend explaining the meaning of the colors used:
plot(net) legend(x=-1.5, y=-1.1, c("Newspaper","Television", "Online News"), pch=21, col="#777777", pt.bg=colrs, pt.cex=2, cex=.8, bty="n", ncol=1)

Sometimes, especially in semantic networks, you only need to display vertex labels:
plot(net, vertex.shape="none", vertex.label=V(net)$media, vertex.label.font=2, vertex.label.color="gray40", vertex.label.cex=.7, edge.color="gray85")

Let's color the edges of the graph in the colors of the vertices from which they emanate. You can find the source vertex of each edge using the
get.edges
function from igraph.
edge.start <- get.edges(net, 1:ecount(net))[,1] edge.col <- V(net)$color[edge.start] plot(net, edge.color=edge.col, edge.curved=.1)
