GGally::ggpairs plot without gridlines when plotting correlation coefficient

StackOverflow https://stackoverflow.com/questions/21810675

  •  12-10-2022
  •  | 
  •  

سؤال

GGally::ggpairs plots nice graphs like following one. Only thing I seek to refine it even more is to remove all gridlines in upper part of plot, where is correlation coefficient. An maybe also draw rectangle around each upper graph.

library("GGally")
data(iris)
ggpairs(iris[, 1:4], lower=list(continuous="smooth", params=c(colour="blue")),
  diag=list(continuous="bar", params=c(colour="blue")), 
  upper=list(params=list(corSize=6)), axisLabels='show')

enter image description here

هل كانت مفيدة؟

المحلول

Check out this related question and my forked repo. Use assignInNamespace to modify ggally_cor function as shown in the aforementioned question.

The only thing that needs to be done is modifying theme call:

  theme(legend.position = "none", 
        panel.grid.major = element_blank(), 
        axis.ticks = element_blank(), 
        panel.border = element_rect(linetype = "dashed", colour = "black", fill = NA))

enter image description here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top