install.packages("ggExtra")
library(ggExtra)
piris <- ggplot(iris, aes(Sepal.Length, Sepal.Width,
color = Species)) +
geom_point(shape=21, size = 3,stroke = 1.2)+
scale_color_npg()+
theme_bw()+
theme(legend.position = c(.1,.86))
ggMarginal(piris, type= 'density',
groupFill = TRUE)

相关系数: