We have seen how to create scatter plots with ggplot() in previous chapters. Therefore, in this section, we will only focus on the parts that we have not seen before. Our objective is to create scatter plots that not only show the scatter plot, but extend it by showing the marginal distributions on both axes. These are called marginal plots and are useful for understanding how data is jointly (two variables) as well as marginally (one variable) distributed.
Scatter plots with joint and marginal distributions
Pricing and profitability by protein source and continent
As usual, we start developing our graph function. We receive as parameters the data, and the variables for the x axis (x) and y axis (y), and, in this case, we...