sgio.plot_matrix_bar3d#

sgio.plot_matrix_bar3d(matrix, fig=None, ax=None, row_labels: Sequence[str] | None = None, col_labels: Sequence[str] | None = None, cmap: str = 'RdBu_r', symlog: bool = True, vmin: float | None = None, vmax: float | None = None, linthresh: float | None = None, bar_width: float = 0.7, **kwargs)#

Plot a 2D matrix as a 3D bar chart using matplotlib bar3d.

Each entry becomes a bar whose height encodes its value and whose color is mapped through cmap with a scale symmetric about 0. By default both the bar heights and the color scale use a symmetric-log mapping, so the large diagonal terms and the tiny coupling terms of a stiffness / compliance matrix are legible together. Positive entries rise; negative entries drop.

Parameters:
  • matrix (array_like) – A 2D array (n_rows x n_cols) to visualize.

  • fig (matplotlib.figure.Figure) – Figure used to attach the colorbar.

  • ax (mpl_toolkits.mplot3d.axes3d.Axes3D) – A 3D axes to plot on. Create with fig.add_subplot(projection='3d').

  • row_labels (sequence of str, optional) – Tick labels for the rows. Defaults to 1 .. n_rows.

  • col_labels (sequence of str, optional) – Tick labels for the columns. Defaults to 1 .. n_cols.

  • cmap (str, optional) – Colormap name. Default 'RdBu_r' (diverging, neutral at 0).

  • symlog (bool, optional) – Use a symmetric-log scale for both bar heights and color. When False a linear scale is used. Default True.

  • vmin (float, optional) – Bounds of the color scale. When both are None the scale spans [-max(|matrix|), +max(|matrix|)]. When only one is given, the other defaults to its negation (symmetric scale).

  • vmax (float, optional) – Bounds of the color scale. When both are None the scale spans [-max(|matrix|), +max(|matrix|)]. When only one is given, the other defaults to its negation (symmetric scale).

  • linthresh (float, optional) – Half-width of the linear region around 0 for the symmetric-log scale (used for both heights and color). Only used when symlog is True. Defaults to the smallest nonzero absolute entry. Must be positive.

  • bar_width (float, optional) – Bar footprint width in cell units (0 < bar_width <= 1). Default 0.7.

  • **kwargs – Extra keyword arguments forwarded to ax.bar3d.

Returns:

The bar collection returned by ax.bar3d.

Return type:

mpl_toolkits.mplot3d.art3d.Poly3DCollection