我们可以用R绘制该图吗?一个具有两个值的网格单元吗?
热图显示了Kuiper距离值(左上方 三角形)和(1-PSS)值(右下三角形)
实际上,该图具有两个相关系数,左上三角为1,右下三角为另一个。有人知道如何在R中绘制该图形吗?
我尝试使用这些软件包,但我做不到。
library(corrplot)
library(ggcorrplot)
library(GGally)
答案 0 :(得分:0)
## First of all define your palette colours with:
### I assume that the dimension of PSS_values= Kuiper_distance_values=8,16
### "ncol1" will be the palette colours for Kuiper distance values (upper-left triangles) while the "ncol2" will for the (1-PSS) values (bottom-right triangles)
color.gradient <- function(x, colors=c(mypal), colsteps=100) {return(colorRampPalette(colors) (colsteps) [ findInterval(x, seq(min(x),max(x), length.out=colsteps)) ] )}
ncol1=matrix(color.gradient(as.vector(Kuiper_distance_values[,rev(1:16)])),nrow=8,ncol=16)
ncol2=matrix(color.gradient(as.vector(PSS_values[,rev(1:16)])),nrow=8,ncol=16)
y=seq(1,16),x=seq(1,8)
par(mfrow=c(1,1))
par(oma=c(15,8,4,2))
plot(1,1,xlim=c(0.75,8.25),ylim=c(0.75,16.25), type="n",bty="n" ,xaxt="n",yaxt="n",xlab="",ylab="")
for(i in 1:8){
for(j in 1:16){
polygon(x[i]-0.5+c(0,1,1),y[j]-0.5+c(0,0,1),col=ncol1[i,j])
polygon(x[i]-0.5+c(0,1,0),y[j]-0.5+c(0,1,1),col=ncol2[i,j])
}}
Listofclimateindex=c("Annuelmean","DJFmean","JJAmean","etc")
Listofclimatemodels=c("ERA5I","MERRA2","CRCM5-OUR","CRCM5-UQAM","CanRCM4","HIRHAM5","RCA4","RegCM4","WRF","ENSmean")
axis(side=2, at= 1:16,labels=rev(Listofclimatemodels), las=1, cex.axis=2,font=2)
axis(side=3, at= 1:8,labels=Listofclimateindex,las=1, cex.axis=2.5,font=2)
abline(h=seq(from=0.5,to=ncol(PSS_values[,rev(1:16)])+0.5,by=1),lty=1,col="white",lwd=1)
abline(v=seq(from=0.5,to=nrow(PSS_values[,rev(1:16)])+0.5,by=1),lty=1,col="white",lwd=1)