data("Tiger")
g <- transition_graph(Tiger)
g
plot_transition_graph(Tiger)
plot_transition_graph(Tiger, vertex.size = 20,
edge.label.cex = .5, edge.arrow.size = .5, margin = .5)
plot_transition_graph(Tiger, vertex.size = 60,
edge.label = NA, edge.arrow.size = .5,
layout = rbind(c(-1,0), c(+1,0)), rescale = FALSE)
## Plot an individual graph for each actions and use a manual layout.
for (a in Tiger$actions) {
plot_transition_graph(Tiger, action = a,
layout = rbind(c(-1,0), c(+1,0)), rescale = FALSE,
main = paste("action:", a))
}
## Plot using the igraph library
library(igraph)
plot(g)
# plot with a fixed layout and curved edges
plot(g,
layout = rbind(c(-1, 0), c(1, 0)), rescale = FALSE,
edge.curved = curve_multiple_directed(g, .8),
edge.loop.angle = -pi / 4,
vertex.size = 60
)
## Use visNetwork (if installed)
if(require(visNetwork)) {
g_vn <- toVisNetworkData(g)
nodes <- g_vn$nodes
edges <- g_vn$edges
# add manual layout
nodes$x <- c(-1, 1) * 200
nodes$y <- 0
visNetwork(nodes, edges) %>%
visNodes(physics = FALSE) %>%
visEdges(smooth = list(type = "curvedCW", roundness = .6), arrows = "to")
}
Run the code above in your browser using DataLab