lets_plot.stat_corr(mapping=None, *, data=None, geom=None, position=None, show_legend=None, sampling=None, tooltips=None, type='full', diag=None, flip=True, threshold=None, **other_args)

Computes correlations between numeric variables in the data and draws a correlation matrix. By default uses the tile geometry.

  • mapping (FeatureSpec) – Set of aesthetic mappings created by aes() function. Aesthetic mappings describe the way that variables in the data are mapped to plot “aesthetics”.

  • data (dict or DataFrame or GeoDataFrame) – The data to be displayed in this layer. If None, the default, the data is inherited from the plot data as specified in the call to ggplot.

  • geom (str) – The name of geometry used to draw correlation matrix. For example: ‘tile’ or ‘point’ or ‘text’.

  • position (str or FeatureSpec) – Position adjustment, either as a string (‘identity’, ‘stack’, ‘dodge’, …), or the result of a call to a position adjustment function.

  • show_legend (bool, default=True) – False - do not show legend for this layer.

  • sampling (FeatureSpec) – Result of the call to the sampling_xxx() function. Value None (or ‘none’) will disable sampling for this layer.

  • tooltips (layer_tooltips) – Result of the call to the layer_tooltips() function. Specifies appearance, style and content.

  • type ({‘upper’, ‘lower’, ‘full’}, default=’full’) – Type of matrix.

  • diag (bool) – Determines whether to fill the main diagonal with values. Default - True if ‘full’ matrix, else - False.

  • flip (bool, default=True) – If True the y axis is flipped.

  • threshold (float, default=0.0) – Minimal correlation abs value to be included in result.


Geom object specification.

Return type



The correlation statistic computes the following variables that can be used in the aesthetic mapping:

  • ..x.. : X coordinates.

  • ..y.. : Y coordinates.

  • ..corr.. : correlation (in range -1..1).

  • ..corr_abs.. : absolute value of correlation (in range 0..1).


1import numpy as np
2from lets_plot import *
5data = {var: np.random.poisson(size=10) for var in 'abcdef'}
6ggplot(data) + stat_corr() + coord_fixed()