微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在散点图矩阵中留下不显着值的空白单元格?

如何解决如何在散点图矩阵中留下不显着值的空白单元格?

我有以下情节

enter image description here

我正在尝试使这个图像这样(手动编辑),其中不重要的单元格为空白

enter image description here

我正在使用这些 r 代码

leg <- grab_legend(ggplot(data=data1,aes(x=NA,y=NA,colour=Si)) +
                     geom_line(size=2) + 
                     theme(legend.direction="horizontal",#change legend title font size
                           legend.title = element_text(size=18),#change legend text font size
                           legend.text = element_text(size=14),#change legend key size
                           legend.key.size = unit(1,'cm')))

my_fn <- function(data1,mapping,method="p",use="pairwise",...){
  
  # grab data
  x <- eval_data_col(data1,mapping$x)
  y <- eval_data_col(data1,mapping$y)
  
  # calculate correlation
  corr <- cor(x,y,method=method,use=use)
  
  # calculate colour based on correlation value
  # Here I have set a correlation of minus one to blue,# zero to white,and one to red 
  # Change this to suit: possibly extend to add as an argument of `my_fn`
  colFn <- colorRampPalette(c("blue","white","red"),interpolate ='spline')
  fill <- colFn(100)[findInterval(corr,seq(-1,1,length=100))]
  
  ggally_cor(data=data1,size=5,mapping=mapping,...) + 
    theme_void() +
    theme(panel.background=element_rect(fill=fill))
}

ggpairs(
  data1,columns=3:7,legend=leg,upper = list(continuous=my_fn),) +
  theme(legend.position='top')+
  theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4,size=12),axis.text.y=element_text(size=12),strip.text = element_text(size = 14))

数据链接https://docs.google.com/spreadsheets/d/1q2iJ1RsRDfZQiT0UskB8PhFDU-_qTDMh2DYv9paE3bM/edit?usp=sharing

我的问题是,

如何绘制具有非显着值的空白单元格的图?谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。