Creates a community-aware network plot in which each community is shown as a circular bubble, with its vertices laid out inside the bubble. Community centres are positioned using a graph layout and subsequently separated to prevent bubbles from overlapping. Larger communities therefore occupy more space in the overall layout.
plot_community_bubbles(
g,
comm = igraph::cluster_infomap(g),
layout = "fr",
inside_layout = "external_fr",
external_measure = "count",
direction = "both",
node_size = NULL,
node_title = NULL,
node_size_ranges = c(4, 16),
node_size_color = FALSE,
edge_width = NULL,
edge_opacity_multiplier = 1,
edge_title = NULL,
label_card = TRUE,
nudge_label = c(-0.1, -0.3),
text_size = 4.5,
text_face = "plain",
bubble_scale = 1,
node_spacing = 1,
bubble_gap = 1,
centre_iterations = 100,
node_clouds = FALSE,
cloudiness = 2,
show_bubbles = TRUE,
fill_bubble = TRUE,
plot_margin = margin(0, 15, 0, 0),
legend_position = NULL,
community_legend = TRUE,
size_legend = TRUE,
edge_legend = TRUE
)An igraph graph object.
Community membership, either an igraph communities object or
a vector with one community ID per vertex. Defaults to
igraph::cluster_infomap().
Layout used for community centres. Supported values include
"fr", "kk", "circle", "drl", "lgl", "graphopt", and
"nicely", or a user-supplied layout function.
Layout used within each community: "circle",
"external", "fr", or "external_fr".
How external connectivity is measured:
"count" counts external edges, while "weighted" sums their weights.
For directed graphs, whether external connectivity is
based on "both", "out", or "in" edges.
Optional vertex attribute name used to scale node size.
Optional title for node sizing on the legend.
Range within which to scale the nodes using node_size. (Default c(4, 16))
Display node size with a monochrome colorbar (Default FALSE)
Optional edge attribute name used to scale edge width.
Tweak opacity of edges by a multiplier. (any float, Default 1 for no tweak, 0 for transparent, 2 for doubling opacity)
Optional title for edge scale on the legend.
Enable a card behind the label for visibility (Default TRUE)
Nudge in position of label from node (Default c(-0.1, -0.3))
Set text size on labels (Default 4.5)
Set text type on labels as passed to ggraph::geom_node_label (Default "plain")
Numeric multiplier controlling bubble size.
Numeric multiplier controlling spacing of vertices within bubbles.
Minimum gap between community bubbles.
Number of iterations used to resolve overlapping community bubbles.
Enable community colored clouds around nodes (Default FALSE)
Intensity of community representing clouds drawn around a node.
Enable drawing of bubble backdrop for communities (Default TRUE)
Margins passed to ggplot2::theme. (Default margin(0, 15, 0, 0))
Legend position parameter passed to ggplot2::theme(). (Default NULL, compute legend position)
Enable color legend for communities (Default: TRUE)
Enable size legend for node sizes (Default: TRUE)
Enable edge legend fo edge widths (Default: TRUE)
Enable filling bubble with shade corresponding to communtiy (Default TRUE)
A ggraph/ggplot object.
Several layouts are available for vertices within communities. "circle"
places vertices evenly around the bubble, "fr" uses a force-directed
layout, and "external" places vertices according to their connectivity
to other communities. "external_fr" combines the latter with the angular
structure of a force-directed layout. In the external layouts, vertices
with many or strong connections outside their community are placed closer
to the community centre, highlighting potential inter-community bridges.
External connectivity can be based on edge counts or edge weights, and can account for incoming, outgoing, or both types of connections in directed graphs.
Certain data like node sizes, node names etc are passed on as igraph
vertex attributes in g. The names of these attributes are then passed
via parameters like node_size or edge_width as strings.
Some attribute names are used automatically if they exist (like name)
The name vertex attribute is used for producing labels for each vertex.
Plots with and witout labels are both automatically produced.
The graph is represented at two levels. First, communities are contracted
into a community-level graph whose vertices are laid out using layout.
Community centres are then iteratively separated according to their bubble
radii, preserving the broad structure of the selected layout while
preventing overlap.
For "external" and "external_fr", each vertex receives an
external-connectivity score based on edges connecting it to other
communities. The score is normalized within each community and controls
the vertex's radial position: highly externally connected vertices are
drawn near the centre, while vertices with predominantly internal
connections are placed toward the perimeter.