[英]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.