Edge coloring in Arc Diagram

  Kiến thức lập trình

I have a dataframe with 3 columns and I create an arc diagram ( source x target).
I don’t know how to colour my edge with st_disease.

Here is my code :

links <- data.frame(
source = c("Convalescent plasma", "Convalescent whole blood", "Gentamicin", "Interferon β-1a", "Lopinavir/ritonavir and recombinant IFN-β1b", "MAb114", "Plasma", "Plasma", "REGN-EB3", "Remdesivir", "Ribavirin", "Ribavirin", "Ribavirin", "Ribavirin", "Ribavirin", "Ribavirin", "Tecovirimat", "ZMapp"),
target = c("No active treatment", "No active treatment", "Doxycycline", "No active treatment", "No active treatment", "ZMapp", "No active treatment", "No active treatment", "ZMapp", "ZMapp", "No active treatment", "No active treatment", "No active treatment", "No active treatment", "No active treatment", "No active treatment", "No active treatment", "Favipiravir"),
st_disease = c("Ebola", "Ebola", "Plague", "Ebola", "MERS", "Ebola", "Lassa fever", "Lassa fever", "Ebola", "Ebola", "Nipah", "Crimean Congo Haemorrhagic Fever", "Crimean Congo Haemorrhagic Fever", "Lassa fever", "Lassa fever", "Lassa fever", "Mpox", "Ebola")
)

mygraph <- graph_from_data_frame(links)
p2 <- ggraph(mygraph, layout="linear") +
geom_edge_arc0(edge_colour="#69b3a2",
edge_alpha=0.3,
edge_width=1.5) +
geom_node_point( color="#69b3a2", size=5, position = "identity") +
geom_node_text( aes(label=name), repel = TRUE, size=4, color="black", nudge_y=-0.5 ,angle=70, vjust=1) +
scale_edge_color_manual(values = col)+
theme_void() +
theme(
legend.position="none",
# plot.margin=unit(rep(2,4), "cm")
plot.margin=unit(c(4,2,2,2), "cm"))+
coord_cartesian(clip = "off")

p2

I tried to change edge_colour but I dot not understand why it’s asking a Aesthetics of length 72.

New contributor

Elise PESONEL is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT