我正在使用包
ggcorrplot
制作相关矩阵。在包中,您可以使用 colors = c(...)
函数为颜色比例尺设置三种颜色的矢量,但是,我想知道是否有办法将比例尺设置为任何 Viridis 调色板?
library(ggplot2)
library(ggcorrplot)
corr <- round(cor(mtcars),1)
ggcorrplot(corr)
ggcorrplot(corr,
colors = c('purple','seagreen3','yellow'))
创建于 2024-05-15,使用 reprex v2.1.0
这个问题是根据@Gregor Thomas 评论回答的
library(ggplot2)
library(ggcorrplot)
library(viridis)
#> Loading required package: viridisLite
corr <- round(cor(mtcars),1)
ggcorrplot(corr) +
scale_fill_gradientn(colors = viridis(256, option = 'D'))
#> Scale for fill is already present.
#> Adding another scale for fill, which will replace the existing scale.
ggcorrplot(corr) +
scale_fill_gradientn(colors = viridis(256, option = 'H'))
#> Scale for fill is already present.
#> Adding another scale for fill, which will replace the existing scale.
创建于 2024-05-15,使用 reprex v2.1.0