Spread igraph node labels by angle from node center
Source:R/jamenrich-igraph.r
spread_igraph_labels.RdSpread igraph node labels by angle from node center
Usage
spread_igraph_labels(
g,
layout = NULL,
y_bias = 1,
update_g_coords = TRUE,
do_reorder = TRUE,
sortAttributes = NULL,
nodeSortBy = c("x", "-y"),
repulse = 3.5,
force_relayout = FALSE,
label_min_dist = 0.5,
verbose = FALSE,
...
)Arguments
- g
igraph object
- layout
numeric matrix representing the x and y coordinates of each node in
g, in the same order asV(g). Whenlayoutis not supplied, nodes are checked for attributesc("x", "y")which define a fixed internal layout. Whenforce_layout=TRUEthese coordinates are ignored. If that is not supplied, thenlayout_with_qfr()is called along with therepulseargument. Subsequent coordinates are stored inV(g)$xandV(g)$ywhen argumentupdate_g_coords=TRUE.- y_bias
numeric value indicating the tendency to spread labels on the y-axis rather than symmetrically around each node. This argument elongates the circle surrounding a node into an ellipse with this ratio.
- update_g_coords
logical indicating whether the layout coordinates will be stored in
graph_attr(g, "layout").- do_reorder
logical indicating whether to call
reorderIgraphNodes()which re-distributes equivalent nodes based upon the node color(s). A node is "equivalent" to another node if both nodes have identical edges.- sortAttributes, nodeSortBy
arguments passed to
reorderIgraphNodes()whendo_reorder=TRUE.- repulse
argument passed to
layout_with_qfr()only whenlayoutis not supplied, and the layout is not stored inc(V(g)$x, V(g)$y).- force_relayout
logical indicating whether the
igraphlayout should be recalculated, in order to override coordinates that may be previously stored in theigraphobject itself. Note that whenlayoutis supplied, it is always used.- label_min_dist
numeric value used to ensure all labels are at least some distance from the center. These units are defined by igraph, and are roughly in units of one line height of text.
- ...
additional arguments are passed to
layout_with_qfr()when needed.
Details
This function uses the igraph vertex attribute
"label.degree", which describes the angular offset for
each vertex label. (The "label.degree" values are
represented as radians, not degrees, starting at 0 for
right, and proceeding clockwise starting from the right,
down, left, top, right.)
This function requires a network layout, which must be fixed in order for the vertex labels to be properly oriented. Labels are oriented opposite the most dominant angular mean of edges from each network node. Typically the side of a node with the fewest edges has the most space to place a label. No further checks are performed for overlapping labels.
Note that this function only modifies the other important
attribute "label.dist" when `label_min_dist“ is defined,
in order to enforce a minimum label distance from the center
of each node. There is no other logic to position small or
large labels to avoid overlapping labels.
See also
Other jam igraph functions:
cnet2df(),
cnet2im(),
cnetplotJam(),
cnetplot_internalJam(),
color_edges_by_nodegroups(),
color_edges_by_nodes(),
color_edges_by_nodes_deprecated(),
color_nodes_by_nodegroups(),
communities2nodegroups(),
drawEllipse(),
edge_bundle_bipartite(),
edge_bundle_nodegroups(),
enrichMapJam(),
fixSetLabels(),
flip_edges(),
get_bipartite_nodeset(),
highlight_edges_by_node(),
igraph2pieGraph(),
jam_igraph(),
jam_plot_igraph(),
label_communities(),
layout_with_qfr(),
layout_with_qfrf(),
mem2emap(),
memIM2cnet(),
mem_multienrichplot(),
nodegroups2communities(),
rectifyPiegraph(),
relayout_with_qfr(),
removeIgraphBlanks(),
removeIgraphSinglets(),
reorderIgraphNodes(),
rotate_igraph_layout(),
subgraph_jam(),
subsetCnetIgraph(),
subset_igraph_components(),
sync_igraph_communities(),
with_qfr()