我想调整ggplot2中的图形区域

时间:2018-07-18 22:34:45

标签: r networking ggplot2

我使用geomnet软件包和ggplot2制作了下图。然后将其导出为pdf。但是图形本身似乎比图形区域大。如您在这张图片中所看到的,它似乎被边框围成一个小方块:

graph

enter image description here

我不知道如何更改构成我的图的正方形的大小,以便净节点将完全显示在pdf中。预先感谢。

这是我正在使用的代码,以及一个数据示例:

red_list<-data_frame(From=c("A","B","C","D","D"),To=c("C","C","D","Z","A"))

red_list%>%ggplot(aes(from_id=From,to_id=To))+
geom_net(layout.alg = "circle", labelon = TRUE,
size = 12, directed = TRUE, fontsize=2, vjust = 0.5, labelcolour = "grey80",
arrowsize = 1.5, linewidth = 0.5, arrowgap = 0.05, col="darkred",
selfloops = F, ecolour = "grey40") + 
theme_net() +
theme(plot.title=element_text(hjust=.5),
plot.subtitle=element_text(hjust=.5))+
ggtitle(label=paste("Figura",i,sep=" "),subtitle = paste("Interacciones entre los sectores de",names(red_list)[i],by=" ")))

1 个答案:

答案 0 :(得分:0)

我不确定它将如何与图形配合使用,但是我经常玩coord_cartesian(xlim = c(...,...), ylim = c(...,...)来调整绘图区域。