Plot behavior adoption on a network
plot_network_adoption.Rd
Visualizes agent behaviors in a network using ggnetwork. Accepts a Trial or AgentBasedModel and colors nodes by behavior.
Arguments
- x
A
Trial
orAgentBasedModel
.- behaviors
Behavior levels. Default:
c("Adaptive", "Legacy")
.- behavior_colors
Color palette. Default: first 2 of
SOCMOD_PALETTE
.- node_size
Single number or named list (e.g.
list(Degree = igraph::degree)
).- label
Whether to show node labels. Default: TRUE.
- plot_mod
A function to modify the ggplot object. Default:
identity
.
Examples
trial <- example_trial()
#> Error in example_trial(): could not find function "example_trial"
plot_network_adoption(trial)
#> Error: object 'trial' not found
# Use degree centrality to size nodes
plot_network_adoption(trial, node_size = list(Degree = igraph::degree))
#> Error: object 'trial' not found
# Add a title and modify legend position
plot_network_adoption(
trial,
plot_mod = . %>%
ggtitle("Adoption at t = 0") %>%
theme(legend.position = "bottom")
)
#> Error: object 'trial' not found
# Specify a circular layout
plot_network_adoption(make_abm(graph = make_small_world(10, 4, 0.2)), layout = "circle")
#> Error in layout$args: $ operator is invalid for atomic vectors