簡體   English   中英

ggraph 弧形圖剪輯 label 文本

[英]ggraph arc diagram clips label text

我正在使用igraphggraph package 到 plot 弧形圖。 我遇到了geom_node_text參數的問題,因為隨着文本 label 的長度增加,圖形下邊距不會相應增加。 因此,如果節點的 label 有點長,它最終會從 plot 中剪掉。

這是一個使用來自igraphdata package 的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")

在此處輸入圖像描述

我已經嘗試通過theme(plot.margin=)更改 plot 邊距,但無論如何標簽都會被剪掉。

您可以在 plot 中設置coord_cartesian(clip = "off")並擴展 plot 邊距:

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"))

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM