为什么当我使用手动坐标获取网络图的子集时缩放比例会发生变化?
Why does the scaling change when I take a subset of a network graph with manual coordinates?
对于这个项目,我正在创建多个网络图,但缩放比例已关闭。第一个网络图包括所有 nodes/categories 并且相当大。其他网络图是完整网络图的子集。为了保持结构,我对每个子集使用与完整图形相同的坐标。问题是每当我创建子集网络时,尽管手动设置了坐标,但缩放比例完全关闭。
完整的网络如下所示:
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
子集的一个例子是:
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
有没有办法维护子集中第一个网络图的结构?或者也许我攻击这一切都是错误的?
不确定这是否有帮助,因为这只是一种预感。但是根据我对图网络的理解,节点的大小通常与其重要性有关。更多 connections/edges = 更大的尺寸(相对于其他节点)。我怀疑在简化模型中,某些节点的相对重要性会由于某些其他节点和边被省略而发生巨大变化。我认为您的问题更多地与节点大小有关,而不是您设置的坐标(可能)。
对于这个项目,我正在创建多个网络图,但缩放比例已关闭。第一个网络图包括所有 nodes/categories 并且相当大。其他网络图是完整网络图的子集。为了保持结构,我对每个子集使用与完整图形相同的坐标。问题是每当我创建子集网络时,尽管手动设置了坐标,但缩放比例完全关闭。
完整的网络如下所示:
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
子集的一个例子是:
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
有没有办法维护子集中第一个网络图的结构?或者也许我攻击这一切都是错误的?
不确定这是否有帮助,因为这只是一种预感。但是根据我对图网络的理解,节点的大小通常与其重要性有关。更多 connections/edges = 更大的尺寸(相对于其他节点)。我怀疑在简化模型中,某些节点的相对重要性会由于某些其他节点和边被省略而发生巨大变化。我认为您的问题更多地与节点大小有关,而不是您设置的坐标(可能)。