ggraph圆弧图剪辑标签文本

ggraph圆弧图剪辑标签文本,r,ggplot2,igraph,ggraph,arc-diagram,R,Ggplot2,Igraph,Ggraph,Arc Diagram,我正在使用igraph和ggraph软件包绘制圆弧图。我在使用geom_node_text参数时遇到问题,因为随着文本标签长度的增加,图形的下边距不会相应增加。因此,如果节点的标签有点长,它最终会从绘图中剪掉 这里是一个使用igraphdata包中的karate样本数据的可复制示例 data(karate) ggraph(karate, layout="linear")+ geom_edge_arc(aes(edge_width=weight), edge_alpha=0.5, fold=T

我正在使用
igraph
ggraph
软件包绘制圆弧图。我在使用
geom_node_text
参数时遇到问题,因为随着文本标签长度的增加,图形的下边距不会相应增加。因此,如果节点的标签有点长,它最终会从绘图中剪掉

这里是一个使用
igraphdata
包中的
karate
样本数据的可复制示例

data(karate)
ggraph(karate, layout="linear")+
  geom_edge_arc(aes(edge_width=weight), edge_alpha=0.5, fold=T)+
  geom_node_point(aes(size=strength(karate), color=as.factor(color)))+
  geom_node_text(aes(label=name), angle=90, hjust=1, nudge_y = -0.2, size=4)+
  theme_void()+theme(legend.position = "none")


我已尝试通过
主题(plot.margin=)
更改绘图页边距,但标签仍会被剪掉。

您可以在绘图中设置坐标(clip=“off”),并展开绘图页边距:

data(karate)

ggraph(karate, layout = "linear") +
  geom_edge_arc(aes(edge_width = weight), edge_alpha = 0.5, fold = TRUE) +
  geom_node_point(aes(size = strength(karate), color = as.factor(color))) +
  geom_node_text(aes(label = name), angle = 90, hjust = 1, nudge_y = -0.2, size = 4) +   
  coord_cartesian(clip = "off") + 
  theme_void() +  
  theme(legend.position = "none", plot.margin = unit(rep(30, 4), "points"))