---
output:
html_document:
code_folding: hide
---
```{r block2, warning=FALSE, message=FALSE, fig.width=8, fig.height=6.5, dev='svg'}
library(ggpubr)
library(cowplot)
pmain <- ggscatter(iris, x = "Sepal.Length", y = "Sepal.Width",
color = "Species", shape ="Species", palette = "jco",
add = "reg.line", conf.int = TRUE,
size = 3, alpha = 0.6, ggtheme = theme_bw()) +
stat_cor(aes(color = Species), show.legend=TRUE) +
guides(color = guide_legend(override.aes = list(label="")))
xdens <- axis_canvas(pmain, axis = "x")+
geom_density(data = iris, aes(x = Sepal.Length, fill = Species),
alpha = 0.7, size = 0.2)+ fill_palette("jco")
ydens <- axis_canvas(pmain, axis = "y", coord_flip = TRUE)+ geom_density(data = iris, aes(x = Sepal.Width, fill = Species),
alpha = 0.7, size = 0.2)+ coord_flip()+ fill_palette("jco")
p1 <- insert_xaxis_grob(pmain, xdens, grid::unit(.2, "null"), position = "top")
p2<- insert_yaxis_grob(p1, ydens, grid::unit(.2, "null"), position = "right")
ggdraw(p2)