R corrplot colorlegend变化范围 [英] R corrplot colorlegend change range

查看:1538
本文介绍了R corrplot colorlegend变化范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 corrplot 包绘制相关矩阵。

我的问题是整个矩阵的最小和最大相关系数的范围是(-0.2,0.2)。我用 corrplot 绘制矩阵,我使用自定义 colorRampPalette ,例如

  col1< -colorRampPalette(c('red','yellow','green','blue'))
/ pre>

用于图例的颜色映射,所以我设置 col = col1(10) cl.lim = c(-0.2,0.2)



当我看到剧情时, -0.2到0.2,但只有2种颜色,而是我想要的是一个colorlegend,整个光谱的颜色在10箱中的自定义调色板,但在范围(-0.2,0.2)所以,而不是只有2种颜色,我会有10种颜色。

解决方案

解决方案是重复的颜色范围, p>

  mypal = jet.colors(1000)#jet.colors from library(matlab)

color = c (mypal,mypal)

corrplot(M,col = color)


I am trying to plot in R a correlation matrix using the corrplot package.
My problem is that the range of min and max correlation coefficients of the entire matrix is (-0.2,0.2). I plot the matrix with corrplot and I use a custom colorRampPalette, say

col1<-colorRampPalette(c('red','yellow','green','blue'))

for the colormap of the legend, so I set col=col1(10), and I set cl.lim=c(-0.2,0.2).

When I see the plot however the colorlegend appears from -0.2 to 0.2 but with just 2 colors, instead what I would like is a colorlegend with the entire spectrum of colors in 10 bins of the custom palette but in range (-0.2,0.2) so instead of having just 2 colors I will have 10 colors.

解决方案

The solution for this was duplicate the color range, so, the get the second half...

mypal = jet.colors(1000) # jet.colors from library(matlab)

color = c(mypal,mypal)

corrplot(M, col=color)

这篇关于R corrplot colorlegend变化范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆