我使用 ggraph 生成了一个非常简单的带有圆形布局的网络图。节点标签的角度沿圆的边缘发生变化,以便于阅读。但是,标签被截断,调整边距似乎没有任何区别。我玩了ggsave,egg,并没有太多的快乐。
这是我的可重现代码。也许有人可以帮助我。提前致谢:
# load network packages
require(tidygraph)
require(igraph)
# fetch data from github
githubURL <- "https://github.com/aterhorst/data/raw/master/network.RDS"
network <- readRDS(url(githubURL))
# compute label angles
require(pracma)
lo <- layout.circle(network)
angle <- as_tibble(cart2pol(lo)) %>% mutate(degree = phi * 180/pi)
# generate plot
require(ggraph)
ggraph(network, layout = "circle") +
geom_edge_link() +
geom_node_point() +
geom_node_text(aes(label = name),
size = 2,
hjust = ifelse(lo[,1] > 0, -0.2, 1.2),
angle = case_when(lo[,2] > 0 & lo[,1] > 0 ~ angle$degree,
lo[,2] < 0 & lo[,1] > 0 ~ angle$degree,
lo[,1] == 1 ~angle$degree,
TRUE ~ angle$degree - 180)) +
theme_graph()