
Map data to vertex sizes or edge widths with an automatic legend
Source:R/plot-scales.R
scale_vertex_size.Rdscale_vertex_size() and scale_edge_width() linearly map a numeric data
vector to a size range and record the mapping so that plot.igraph() draws a
matching legend. Pass the result to vertex.size or edge.width, e.g.
plot(g, vertex.size = scale_vertex_size(degree(g))).
Arguments
- x
A numeric data vector to map. Its length must be 1 or the number of vertices (edges) of the graph it is used with.
- ...
These dots are for future extensions and must be empty.
- range
Numeric length-2 vector giving the output size range.
- na_value
Size used for
NAentries inx, and for entries that the transformation maps to a non-finite value (such as0under"log"). Defaults to the smallest size ofrange.- name
Optional guide title; defaults to the argument name.
- trans
Optional transformation applied to
xbefore rescaling, given as a function or its name (e.g."sqrt","log"). For"log","log2","log10"and"sqrt", the legend uses breaks that are evenly spaced on the transformed scale.
Details
The keys of a vertex size legend are proportional to one another but are not drawn at the size of the plotted vertices, which depends on the device and the layout; they are kept within a legible range instead. The line samples of an edge width legend use the mapped widths directly.
See also
Other scales:
scale_vertex_color()

