For this project I'm creating several network graphs, but the scaling is off. The first network graph includes all of the nodes/categories and is rather large. The other network graphs are subsets of the full one. I'm using the same coordinates for each subset as the full graph in order to maintain the structure. The problem is that whenever I create a subset network, the scaling is completely off, despite having manually set the coordinates.
The full network looks like this:
nodes<- read_csv("node_coords.csv")
viz_all <- visNetwork(sort(gvis$nodes),gvis$edges,main="All Connections",width = "100%",height = "850px") %>%
visLayout(randomSeed = 123) %>%
visEdges(smooth =T,
arrows =list(to = list(enabled = TRUE, scaleFactor = .5)),
color = list(highlight = "black")) %>% #https://datastorm-open.github.io/visNetwork/edges.html
visPhysics(stabilization = FALSE) %>%
visIgraphLayout(smooth=FALSE,physics=FALSE, layout="layout_with_fr", layoutMatrix = gcoords) %>%
visLayout(randomSeed=123,improvedLayout = TRUE)%>%
visInteraction(navigationButtons = TRUE)%>%
visOptions(selectedBy = list(variable = c("program"), multiple = TRUE),
highlightNearest = list(enabled = T, hover = T),
nodesIdSelection = TRUE)%>%
addFontAwesome() %>%
visLegend(position = "left",addNodes = lnodes, useGroups = FALSE,stepY=100)
viz_all$x$nodes <- viz_all$x$nodes %>% left_join(nodes, by = 'id') %>% select(-c('x.x', 'y.x')) %>% rename(x = x.y, y=y.y)
viz_all
And an example of a subset is this:
viz_ag <- visNetwork(sort(gvis_agriculture$nodes),gvis_agriculture$edges, main="Agriculture Subset",width = "100%",height = "850px") %>%
visLayout(randomSeed = 123) %>%
visEdges(smooth =T,
arrows =list(to = list(enabled = TRUE, scaleFactor = .5)),
color = list(color = "lightblue", highlight = "black")) %>% #https://datastorm-open.github.io/visNetwork/edges.html
visPhysics(stabilization = FALSE) %>%
visIgraphLayout(smooth=FALSE,physics=FALSE, layout="layout_with_fr") %>%
visLayout(randomSeed = 123,improvedLayout = TRUE)%>%
visInteraction(navigationButtons = TRUE)%>%
visOptions(selectedBy = list(variable = c("program"), multiple = TRUE),
highlightNearest = list(enabled = T, hover = T),
nodesIdSelection = TRUE)%>%
addFontAwesome() %>%
visLegend(position = "left", useGroups = FALSE,stepY=100)
viz_ag$x$nodes <- viz_ag$x$nodes %>% left_join(nodes, by = 'id') %>% select(-c('x.x', 'y.x')) %>% rename(x = x.y, y=y.y)
viz_ag
Is there anyway to maintain the structure of the first network graph in the subsets? Or maybe I'm attacking this all wrong?