anyplotlib.subplots#

anyplotlib.subplots(nrows=1, ncols=1, *, sharex=False, sharey=False, figsize=(640, 480), width_ratios=None, height_ratios=None, gridspec_kw=None, display_stats=False, help='')[source]#

Create a Figure and a grid of Axes.

Mirrors matplotlib.pyplot.subplots().

Parameters:
  • nrows (int) – Number of rows and columns in the grid.

  • ncols (int) – Number of rows and columns in the grid.

  • sharex (bool) – Link pan/zoom across all panels on the respective axis.

  • sharey (bool) – Link pan/zoom across all panels on the respective axis.

  • figsize ((width, height)) – Figure size in CSS pixels. Default (640, 480).

  • width_ratios (list of float, optional) – Relative column widths. Equivalent to gridspec_kw={"width_ratios": ...}.

  • height_ratios (list of float, optional) – Relative row heights. Equivalent to gridspec_kw={"height_ratios": ...}.

  • gridspec_kw (dict, optional) – Extra keyword arguments forwarded to GridSpec. Recognised keys: width_ratios, height_ratios.

  • display_stats (bool, optional) – Show per-panel FPS / frame-time overlay. Default False.

  • help (str, optional) – Help text shown when the user clicks the ? badge on the figure. Newlines (\n) create separate lines in the card. The badge is hidden when help is empty (default). Suppressed globally when apl.show_help = False.

Returns:

  • fig (Figure)

  • axs (Axes or numpy array of Axes) –

    • Single cell → scalar Axes.

    • Single row → 1-D array of shape (ncols,).

    • Single column → 1-D array of shape (nrows,).

    • Otherwise → 2-D array of shape (nrows, ncols).

Examples

>>> import anyplotlib as vw
>>> import numpy as np
>>> fig, axs = vw.subplots(2, 1, figsize=(640, 600))
>>> v2d = axs[0].imshow(np.random.rand(128, 128))
>>> v1d = axs[1].plot(np.sin(np.linspace(0, 6.28, 256)))
>>> fig