Skip to content
Correlation Plot

Correlation Plot

A correlation plot.

Correlation Plot

Usage

from dataviz_mojo import corrplot
from dataviz_mojo.plot import save

def main() raises:
    var variables: List[String] = ["Horsepower", "MPG", "Weight", "Price"]
    var matrix: List[List[Float64]] = [
        [1.0, -0.78, 0.66, 0.72],
        [-0.78, 1.0, -0.83, -0.55],
        [0.66, -0.83, 1.0, 0.48],
        [0.72, -0.55, 0.48, 1.0],
    ]

    var c = corrplot(variables, matrix, layout="upper", diag=False)
    save(c, "docs/src/examples/out_corrplot.svg")

Args:

  • variables: One row and one column per entry – matrix must be this length square.
  • matrix: The square pairwise-correlation matrix, each value in [-1.0, 1.0].
  • layout: Which triangle of matrix to draw – "full" (the default), "lower", or "upper".
  • diag: Whether to draw the diagonal cells (variables[i] against itself); defaults to True.
  • labels: Whether to draw variables’ names along the axes; defaults to True.
  • theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – see Theme’s docstring.
  • width: Pixel width of the returned Plot (.size()).
  • height: Pixel height of the returned Plot (.size()).
  • title: The chart’s title, shown above the plot.
  • subtitle: A secondary line shown under the title.
  • x_title: The x-axis caption.
  • y_title: The y-axis caption.