[英]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),其中“填充”将毫无意义。 指定形状和调整笔画会有所帮助。
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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.