View source: R/edge_direction.R
guide_edge_direction | R Documentation |
This guide is intended to show the direction of edges based on the aesthetics mapped to its progression, such as changing width, colour and opacity.
guide_edge_direction(
title = NULL,
theme = NULL,
arrow = NULL,
labels = NULL,
nbin = 500,
position = NULL,
direction = NULL,
reverse = FALSE,
order = 0,
override.aes = list(),
...,
available_aes = c("edge_colour", "edge_alpha", "edge_width"),
arrow.position = deprecated()
)
gr <- tidygraph::as_tbl_graph(highschool)
ggraph(gr, layout = 'kk') +
geom_edge_fan(aes(alpha = after_stat(index))) +
guides(edge_alpha = guide_edge_direction())
# Use text labels instead of an arrow
ggraph(gr, layout = 'kk') +
geom_edge_fan(aes(alpha = after_stat(index))) +
guides(edge_alpha = guide_edge_direction(labels = c('start', 'end')))
# Style the indicator arrow
arrow_style <- element_line(linewidth = 3, arrow = grid::arrow(type = "closed"))
ggraph(gr, layout = 'kk') +
geom_edge_fan(aes(alpha = after_stat(index))) +
guides(
edge_alpha = guide_edge_direction(
theme = theme(legend.axis.line = arrow_style)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.