跳到内容

这是来自 https://colorbrewer2.org/ 的 ‘PuOr’ 调色板。它最多有 11 种颜色。

用法

diverging_pal(n)

参数

n

调色板中的颜色数量。当前最大值为 11。

RGB 颜色代码的字符向量。

详细信息

这与 sequential_pal() 类似,但它也强调了中间范围的值,以及两个极端端点。如果您有这样一个数量需要用顶点颜色标记,请使用此调色板。

参见

其他调色板:categorical_pal()r_pal()sequential_pal()

示例

library(igraphdata)
data(foodwebs)
fw <- foodwebs[[1]] %>%
  induced_subgraph(V(.)[ECO == 1]) %>%
  add_layout_(with_fr()) %>%
  set_vertex_attr("label", value = seq_len(gorder(.))) %>%
  set_vertex_attr("size", value = 10) %>%
  set_edge_attr("arrow.size", value = 0.3)
#> This graph was created by an old(er) igraph version.
#>  Call `igraph::upgrade_graph()` on it to use with the current igraph version.
#> For now we convert it on the fly...

V(fw)$color <- scales::dscale(V(fw)$Biomass %>% cut(10), diverging_pal)
plot(fw)


data(karate)
karate <- karate %>%
  add_layout_(with_kk()) %>%
  set_vertex_attr("size", value = 10)
#> This graph was created by an old(er) igraph version.
#>  Call `igraph::upgrade_graph()` on it to use with the current igraph version.
#> For now we convert it on the fly...

V(karate)$color <- scales::dscale(degree(karate) %>% cut(5), diverging_pal)
plot(karate)