Skip to content

Instantly share code, notes, and snippets.

@z3tt
Last active March 18, 2021 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z3tt/7ad6e3903790832c6ed8f4c7f05a765b to your computer and use it in GitHub Desktop.
Save z3tt/7ad6e3903790832c6ed8f4c7f05a765b to your computer and use it in GitHub Desktop.
arc graph example for sorting
library(tidyverse)
library(igraph)
library(ggraph)
df <- readRDS("data.Rds")
graph <- graph_from_data_frame(df)
sorting <- c(25, 24, 1, 2, 3, 4, 5, 6, 7, 8, 26, 27, c(9:23))
ggraph(graph, layout = 'linear', sort.by = sorting) + #
geom_edge_arc(
aes(color = factor(edge),
edge_width = factor(edge),
alpha = factor(edge)),
fold = TRUE
) +
geom_node_point(
aes(color = str_sub(name, 0, 1)),
shape = 21,
fill = "white",
size = 10,
stroke = 2
) +
geom_node_text(
aes(label = name),
family = "Oswald",
size = 3.3
) +
coord_cartesian(clip = 'off') +
scale_edge_color_manual(values = c("grey80", "#d69d05", "#8b6603", "#036c8b", "#94b5be"),
name = "Output:") + ## blau
scale_edge_alpha_manual(values = c(1, 1, .7, .7, .7), name = "Output:") +
scale_edge_width_manual(values = c(1.2, 1, .8, .6, .4), name = "Output:") +
theme(legend.position = "bottom")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment