plotting.hinton#

Hinton diagram visualization.

Functions

hinton_diagram

Draw a Hinton diagram of a matrix.


hinton_diagram(
matrix: ndarray,
max_weight: float | None = None,
ax: Axes | None = None,
) None[source]#

Draw a Hinton diagram of a matrix.

The color of each square reflects the sign of the corresponding matrix element, and the size of each square reflects the magnitude of the corresponding element.

Code adapted from here.

Parameters:
matrixndarray of shape (M, N)

Matrix to visualize.

max_weightfloat or None, default None

Maximum absolute value of matrix elements.

axAxes or None, default None

Axes on which to draw the diagram. If None, gets an existing axis or creates a new one.

Examples

>>> import numpy as np
>>> from latents.plotting import hinton_diagram
>>> C = np.random.normal(size=(10, 5))
>>> hinton_diagram(C)