Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. install.packages('arcdiagram')
  2.  
  3. library(devtools)
  4. install_github('gastonstat/arcdiagram')
  5.  
  6. library(arcdiagram)
  7.  
  8. # create a star graph with 10 nodes
  9. star_graph = graph.star(10, mode="out")
  10.  
  11. # extract edgelist
  12. star_edges = get.edgelist(star_graph)
  13.  
  14. # inspect star_edges
  15. star_edges
  16.  
  17. # plot 1: default arc diagram
  18. arcplot(star_edges)
  19.  
  20. # plot 2: show nodes as circles, in decreasing order
  21. arcplot(star_edges, show.nodes=TRUE, sorted=TRUE, decreasing=TRUE, las=1)
  22.  
  23. # plot 3: different ordering, arc widths, arc colors, and node sizes
  24. set.seed(120)
  25. arcplot(star_edges, ordering=sample(1:10), labels=paste("node",1:10,sep="-"),
  26. lwd.arcs=4*runif(10,.5,2), col.arcs=hsv(runif(9,0.6,0.8),alpha=0.4),
  27. show.nodes=TRUE, pch.nodes=21, cex.nodes=runif(10,1,3),
  28. col.nodes="gray80", bg.nodes="gray90", lwd.nodes=2)
  29.  
  30. # plot 4: same as plot 3 but vertically oriented
  31. set.seed(120)
  32. op = par(mar = c(0.5, 5, 0.5, 3))
  33. arcplot(star_edges, ordering=sample(1:10), horizontal=FALSE,
  34. labels=paste("node",1:10,sep="-"),
  35. lwd.arcs=4*runif(10,.5,2), col.arcs=hsv(runif(9,0.6,0.8),alpha=0.4),
  36. show.nodes=TRUE, pch.nodes=21, cex.nodes=runif(10,1,3),
  37. col.nodes="gray80", bg.nodes="gray90", lwd.nodes=2)
  38. par(op)
  39.  
  40. arcplot(star_edges)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement