-1

I found this graphical intuitive explanation of covariance: 32 binormal points drawn from distributions with the given covariances, ordered from most negative (bluest) to most positive (reddest)

enter image description here

The whole material can be found at: https://stats.stackexchange.com/questions/18058/how-would-you-explain-covariance-to-someone-who-understands-only-the-mean

I would like to recreate this sort of graphical illustration in R, but I'm not sufficiently familiar with R's plotting tools. I don't even know where to start in order to get those colored rectangles between each pair of data points, let alone make them semi-transparent.

I think this could make a very efficient teaching tool.

Community
  • 1
  • 1
Claudiu Papasteri
  • 2,469
  • 1
  • 17
  • 30
  • 1
    While an interesting question, SO is not a code-writing service. Show some of your effort/a specifice plotting issue you're having trouble with. Please consider reading up on [ask] and how to produce a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Heroka Dec 30 '15 at 16:57

1 Answers1

0

The cor.rect.plot function in the TeachingDemos package makes plots similar to what is shown. You can modify the code for the function to make the plot even more similar if you desire.

Greg Snow
  • 48,497
  • 6
  • 83
  • 110
  • Thank you. I have since found how to do it in ggplot2 that makes the graphics even more similar to the ones above. – Claudiu Papasteri Jan 05 '16 at 16:21
  • @ClaudiuPapasteri, you should include your final answer so that people who find this question in the future can see what you did. – Greg Snow Jan 05 '16 at 18:00
  • @ Greg Snow I know and I will as soon as I refine it further. I want it look as similar as possible to the example above, but I'm having some problems with overlapping colors. – Claudiu Papasteri Jan 06 '16 at 14:47