Ggraph似乎无法显示图例
我想根据与节点关联的值为节点创建不同的大小 我得到的是这些奇怪的数字表情符号,而不是我所期望的图例标签 我在linux机器上使用RStudio服务器,我在ggplot中没有出现此错误 这是我的想象 这是我的密码Ggraph似乎无法显示图例,r,ggraph,R,Ggraph,我想根据与节点关联的值为节点创建不同的大小 我得到的是这些奇怪的数字表情符号,而不是我所期望的图例标签 我在linux机器上使用RStudio服务器,我在ggplot中没有出现此错误 这是我的想象 这是我的密码 library(GGraph) library(network) netval1 <- network(netmat1_matrix, matrix.type = "edgelist") netval1_tidy <- as_tbl_gr
library(GGraph)
library(network)
netval1 <-
network(netmat1_matrix, matrix.type = "edgelist")
netval1_tidy <-
as_tbl_graph(netval1)
ggraph(netval1_tidy) +
geom_edge_link() +
geom_node_point(aes(size = (c))) +
theme_graph()
你的审美观在这里似乎是个问题。考虑下面的样本数据。
num_nodes <- 10
my_sociomatrix <- matrix(round(runif(num_nodes*num_nodes)), # edge values
nrow = num_nodes, #nrow must be same as ncol
ncol = num_nodes)
diag(my_sociomatrix) <- 0
net <- as.network(x = my_sociomatrix, # the network object
directed = TRUE, # specify whether the network is directed
loops = FALSE, # do we allow self ties (should not allow them)
matrix.type = "adjacency" # the type of input
)
network.vertex.names(net) <- LETTERS[1:10]
# Create the variable
gender <- c(rep("Female",num_nodes/2),rep("Male",num_nodes/2))
# Add it to the network object
set.vertex.attribute(net, # the name of the network object
"Gender", # the name we want to reference the variable by in that object
gender # the value we are giving that variable
)
age <- round(rnorm(num_nodes,20,3))
set.vertex.attribute(net,"Age",age)
summary.network(net, # the network we want to look at
print.adj = FALSE # if TRUE then this will print out the whole adjacency matrix.
)
num_nodes <- 10
my_sociomatrix <- matrix(round(runif(num_nodes*num_nodes)), # edge values
nrow = num_nodes, #nrow must be same as ncol
ncol = num_nodes)
diag(my_sociomatrix) <- 0
net <- as.network(x = my_sociomatrix, # the network object
directed = TRUE, # specify whether the network is directed
loops = FALSE, # do we allow self ties (should not allow them)
matrix.type = "adjacency" # the type of input
)
network.vertex.names(net) <- LETTERS[1:10]
# Create the variable
gender <- c(rep("Female",num_nodes/2),rep("Male",num_nodes/2))
# Add it to the network object
set.vertex.attribute(net, # the name of the network object
"Gender", # the name we want to reference the variable by in that object
gender # the value we are giving that variable
)
age <- round(rnorm(num_nodes,20,3))
set.vertex.attribute(net,"Age",age)
summary.network(net, # the network we want to look at
print.adj = FALSE # if TRUE then this will print out the whole adjacency matrix.
)
ggraph(net) +
geom_edge_link() +
geom_node_point(aes(size=age/5)) +
theme_graph()