Correlation Matrix
This visualization displays a correlation matrix for 26 randomly generated variables, where each cell’s color indicates the correlation strength between two variables. The data is synthesized with random numbers, and the matrix reveals that most correlations are near zero, with only the diagonal showing perfect correlation. The implementation computes correlations using jeezy's `correlationMatrix` function, arranges the cells with data2grid, and maps colors with a chroma scale from tomato through white to steelblue. D3 v4 renders the SVG grid, while hover interactions highlight corresponding rows, columns, and a tooltip showing the exact correlation value.
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>