Skip to main content
100%

Correlation Matrix

✓ Published0🌍 Public
AAlainRo
Last edited Jan 14, 2019
Created on Jan 14, 2019

This visualization displays a correlation matrix for 26 randomly generated variables (columns a through z), with each cell’s color indicating the correlation strength between variable pairs. The heatmap uses a red-white-blue color scale, and hovering over a cell highlights the corresponding row and column labels while showing the exact correlation value in a tooltip. The example computes the correlation matrix with jeezy's correlationMatrix function, arranges the cells using data2grid, and renders them as SVG rectangles with d3.v4. Chroma.js generates the color scale, and the visualization includes animated opacity transitions and interactive hover effects.

AI-generated description

Here'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>

gpl-3.0 Licensed

Similar vizzes