ggraph 指定节点的填充和颜色
ggraph specify both fill and colour of nodes
我已经看到 如何从美学中获取节点填充并将颜色设置为在节点周围有黑色边距。但是,如果我尝试指定固定颜色 和 填充,我只会得到黑色节点。
ggraph(igraph::graph_from_adjacency_matrix(matrix(sample(0:1, 100, replace=TRUE,
prob=c(0.8,0.2)), nrow=10),
mode='undirected', diag=F)) +
geom_edge_link(colour = "grey") +
geom_node_point(fill = "red",
colour = "black",
size = 10) +
theme(legend.position = 'none') +
theme_graph(background = "white")
在这种情况下如何指定颜色?
默认情况下,它采用实心形状(形状 = 19),其中 'fill' 将毫无意义。指定形状和调整笔触会有所帮助。
ggraph(igraph::graph_from_adjacency_matrix(matrix(sample(0:1, 100, replace=TRUE,
prob=c(0.8,0.2)), nrow=10),
mode='undirected', diag=F)) +
geom_edge_link(colour = "grey") +
geom_node_point(fill = "red",
colour = "black",
size =10,
shape = 21, # Change the shape
stroke = 2) + # Specify the width of margin
theme(legend.position = 'none') +
theme_graph(background = "white")
我已经看到
ggraph(igraph::graph_from_adjacency_matrix(matrix(sample(0:1, 100, replace=TRUE,
prob=c(0.8,0.2)), nrow=10),
mode='undirected', diag=F)) +
geom_edge_link(colour = "grey") +
geom_node_point(fill = "red",
colour = "black",
size = 10) +
theme(legend.position = 'none') +
theme_graph(background = "white")
在这种情况下如何指定颜色?
默认情况下,它采用实心形状(形状 = 19),其中 'fill' 将毫无意义。指定形状和调整笔触会有所帮助。
ggraph(igraph::graph_from_adjacency_matrix(matrix(sample(0:1, 100, replace=TRUE,
prob=c(0.8,0.2)), nrow=10),
mode='undirected', diag=F)) +
geom_edge_link(colour = "grey") +
geom_node_point(fill = "red",
colour = "black",
size =10,
shape = 21, # Change the shape
stroke = 2) + # Specify the width of margin
theme(legend.position = 'none') +
theme_graph(background = "white")