我使用 ggraph 制作并使用 ggnetwork 中的 geom_nodelabel_repel() 添加了标签:
( ggraph_plot <- ggraph(layout) +
geom_edge_fan(aes(color = as.factor(responses), edge_width = as.factor(responses))) +
geom_node_point(aes(color = as.factor(group)), size = 10) +
geom_nodelabel_repel(aes(label = name, x=x, y=y), segment.size = 1, segment.color = "black", size = 5) +
scale_color_manual("Group", values = c("#2b83ba", "#d7191c", "#fdae61")) +
scale_edge_color_manual("Frequency of Communication", values = c("Once a week or more" = "#444444","Monthly" = "#777777",
"Once every 3 months" = "#888888", "Once a year" = "#999999"),
limits = c("Once a week or more", "Monthly", "Once every 3 months", "Once a year")) +
scale_edge_width_manual("Frequency of Communication", values = c("Once a week or more" = 3,"Monthly" = 2,
"Once every 3 months" = 1, "Once a year" = 0.25),
limits = c("Once a week or more", "Monthly", "Once every 3 months", "Once a year")) +
theme_void() +
theme(legend.text = element_text(size=16, face="bold"),
legend.title = element_text(size=16, face="bold")) )
我想让情节左侧的标签偏向左侧,而情节右侧的标签偏向右侧。我想这样做是因为实际标签很长(组织名称),并且它们妨碍了实际情节中的线条。
如何使用 geom_nodelabel_repel() 做到这一点?我尝试了 box_padding 和 point_padding 以及 h_just 和 v_just 的不同组合,但这些组合适用于所有标签,而且似乎没有办法对特定点进行子集化或定位。
很抱歉没有提供可重复的示例,但我不确定如何在不影响调查中受访者身份的情况下做到这一点。