How to draw scatter plot and mosaic density Diagram by ggplot2
Ggplot2 how to draw scatter plot splicing density map, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Image.png
A few days ago, a reader left a message on the official account and asked how the above picture should be realized. I thought of a way to use ggplot2 to draw scatter plot and density diagram respectively, and then use aplot package to do the puzzle. Aplot package is a new package developed by the author of ggtree. A very important role is to solve the problem of axis alignment in jigsaw puzzles. The usage of this aplot package you can search aplot directly in Wechat search to find the introduction of the original author's tweet, and this official account often pushes the learning content of R language, very good, the author is a real god-level figure.
Aplot package: allows you to draw more complex pictures
All right, let's start to introduce the specific implementation process.
The first is the simulation data.
Generate two columns of data that conform to normal distribution, and then combine them into a data box
X