Does anyone know how to superimpose a rotated density plot and/or histogram on the right-hand-side of a scatter plot? I'm agnostic about what software could be used to do this...ideally it would be R.

My primary goal is to explain QQplots. In the one below, we have theoretical quantiles on the x-axis, and sample quantiles on the y-axis. I want to superimpose a bell curve on the x-axis, and show how each x-coordinate is a quantile, and then I want to show how each y-coordinate is a quantile on histogram/bell-curve as well. To do this I would place a histogram or bell curve on the right hand side of the plot, rotated counter-clockwise 45 degrees.

Being able to do this would help making cooler-looking trace plots for MCMC diagnostics as well. enter image description here


closed as off-topic by Robert Long, Michael Chernick, user158565, mkt, Peter Flom Jul 13 at 13:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Michael Chernick, user158565, mkt, Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ The last figure in my post at stats.stackexchange.com/a/86804/919 used Mathematica for a graphic like the one you describe. I suspect that because your question presently is software-oriented, it's likely to be closed quickly: but if you would rephrase it to ask how to visually explain a QQ plot, or something like that, our readers might be more forgiving. $\endgroup$ – whuber Jul 12 at 21:22
  • $\begingroup$ I've written a paper on how to do this in SAS but a) Questions about coding are off topic here and b) It looks like you are using R $\endgroup$ – Peter Flom Jul 13 at 13:52