Correlation Matrix
This correlation matrix visualizes the relationships between 26 random variables (columns a–z) across 31 data points, using a color scale from tomato to steelblue to represent correlation strength, ignoring perfect self-correlations. Built with D3 v4 and the jeezy and data2grid libraries, the grid renders as an SVG with smooth opacity transitions. Users can hover over any cell to see the exact correlation value in a tooltip, while the corresponding row and column labels highlight in bold green to clarify the pair. The axes display the variable names along both dimensions, and the color scale uses a diverging white midpoint to emphasize positive versus negative correlations.
AI-generated descriptionHere's some reusable code to compute and draw a correlation matrix from a set of data in JavaScript. Here's how it works:
- jeezy's correlationMatrix function calculates a correlation matrix for a set of data.
- data2grid sets up a layout for that correlation matrix.
- chroma creates a color scale based on the extents of the correlation matrix (in this case it ignores correlations of 1, because the data set is random and so all correlations are quite low other than when both columns are the same).
- d3 draws the correlation matrix to the DOM.
forked from <a href='http://bl.ocks.org/HarryStevens/'>HarryStevens</a>'s block: <a href='http://bl.ocks.org/HarryStevens/302d078a089caf5aeb13e480b86fdaeb'>Correlation Matrix</a>
forked from <a href='http://bl.ocks.org/willzjc/'>willzjc</a>'s block: <a href='http://bl.ocks.org/willzjc/3553cc0400957131fcb5b99e4db77ade'>Correlation Matrix</a>