Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 包括使用ggplot修改的ggnet2对象的节点大小图例_R_Ggplot2_Ggnetwork - Fatal编程技术网

R 包括使用ggplot修改的ggnet2对象的节点大小图例

R 包括使用ggplot修改的ggnet2对象的节点大小图例,r,ggplot2,ggnetwork,R,Ggplot2,Ggnetwork,我正在使用ggplot2修改aggnet对象以增加节点的大小。但是,如果使用这种方法,则无法在图例中包含尺寸参数。我尝试了scale\u size\u手册和将大小包含在aes方法中,但仍然没有成功 library(network) library(dplyr) library(ggplot2) library(GGally) # weighted adjacency matrix bip = data.frame(event1 = c(1, 2, 1, 0),

我正在使用
ggplot2
修改a
ggnet
对象以增加节点的大小。但是,如果使用这种方法,则无法在图例中包含尺寸参数。我尝试了
scale\u size\u手册
和将大小包含在
aes
方法中,但仍然没有成功

library(network)
library(dplyr)
library(ggplot2)
library(GGally)

# weighted adjacency matrix
bip = data.frame(event1 = c(1, 2, 1, 0),
                 event2 = c(0, 0, 3, 0),
                 event3 = c(1, 1, 0, 4),
                 row.names = letters[1:4])

# weighted bipartite network
bip = network(bip,
              matrix.type = "bipartite",
              ignore.eval = FALSE,
              names.eval = "weights")
# set colors for each mode
col = c("actor" = "grey", "event" = "gold")

## I have tried including the size in the ggnet2 but the points are not as big as I want
p <- ggnet2(bip, color = "mode",  label = F,  shape = "mode",
            palette = col,
            shape.palette=c(24,19))

## add a size variable to the network data
p$data <- p$data %>% 
  mutate(index=1:7)

## create a vector of the sizes
aa <- p$data$index
 p +
      geom_point(aes(color = color, shape=shape), size = aa*2, color = "#92D050") +
      geom_point(aes(color = color),  alpha = 0.1) +
      geom_text(aes(label = toupper(label )), color = "black", fontface = "bold", size=3 ,
                position = position_nudge(y = -0.015)) +
      scale_size_manual(name="Antigen" ,values=p$data$index ,
                        guide = "legend",
                        guide_legend(override.aes = list(size=c(1,2,3,4,5,6,7)))) +
      guides(color = FALSE) + 
      theme_minimal()