garthtarr / edgebundleR

Circle plot with bundled edges
http://garthtarr.github.io/edgebundleR/
66 stars 12 forks source link

Feature Request: Ordering nodes #6

Open aliarsalankazmi opened 8 years ago

aliarsalankazmi commented 8 years ago

Thank you for the great work, garthtarr and timelyportfolio!

I think it may be worth adding an order argument for the nodes. I think it will be a fairly common use case when one will have a lot of groups/classes in their data. Although they can colour these, but even if we have 5 groups of a thousand observations, it becomes difficult to spot patterns in the data.

Adding an order argument will be able to show if certain groups have intra/inter-groups linkage.

garthtarr commented 8 years ago

@aliarsalankazmi yes indeed that would be useful. I don't have time right now to implement such a feature, hopefully I'll find some time in the next few months.

garthtarr commented 8 years ago

As a start, I've disabled the automatic alphabetical ordering of the nodes. They should now maintain the order from the data that is passed through.

aliarsalankazmi commented 8 years ago

Thanks!

ErasmuszuE commented 4 years ago

Hey @garthtarr, I just came across this great package, thank you!

Any update on the issue of node order? And when you say (in your answer on May 28, 2016 ) that the 2016 fix means 'they should now maintain the order from the data that is passed through.', what do you mean by the 'order that the data are passed through'? When I change the order of the rows in the data passed to graph.data.frame(), it doesn't change the order of the nodes in the final figure. Example code below - thanks for your help!


library(igraph)
library(edgebundleR)

# vertices
nodes <- 
  tibble("name" = letters[seq( from = 1, to = 10 )],
         "type" = c(rep("one", 5), rep("two", 5))
) %>%
  arrange(desc(type))

# relationsips
edges <- 
  nodes %>%
  select(from = name) %>%
  mutate(to = 
           case_when(from == "a" ~ "b",
                     from == "b" ~ "d",
                     TRUE ~ "g"))

# make igraph object 
g <- graph.data.frame(edges, directed=F, vertices=nodes)

# Plot
# ... is ordered a->h, not by 'type', i.e. f,g,h,i,j,a,b,c,d,e
edgebundle(g)