.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/get_figsize.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_get_figsize.py: Get Figure Size ===================================== :func:`sysplot.get_figsize` returns a ``(width, height)`` tuple scaled to a subplot grid. It multiplies the base figure size from :class:`sysplot.SysplotConfig` by the number of columns and rows, capping each dimension at ``nmax`` times the base size. .. GENERATED FROM PYTHON SOURCE LINES 9-43 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /_auto_examples/images/sphx_glr_get_figsize_001.png :alt: 1×1 grid :srcset: /_auto_examples/images/sphx_glr_get_figsize_001.png :class: sphx-glr-multi-img * .. image-sg:: /_auto_examples/images/sphx_glr_get_figsize_002.png :alt: Left, Right :srcset: /_auto_examples/images/sphx_glr_get_figsize_002.png :class: sphx-glr-multi-img * .. image-sg:: /_auto_examples/images/sphx_glr_get_figsize_003.png :alt: get figsize :srcset: /_auto_examples/images/sphx_glr_get_figsize_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none 1×1: (7.0, 5.0) 1×2: (14.0, 5.0) 1×5 nmax=2: (14.0, 5.0) | .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import sysplot as ssp ssp.apply_config() x = np.linspace(0, 2 * np.pi, 200) # 1×1 — base figure size size = ssp.get_figsize() print(f"1×1: {size}") fig, ax = plt.subplots(figsize=size) ax.plot(x, np.sin(x)) ax.set(title="1×1 grid", xlabel="x", ylabel="y") plt.show() # 1×2 — width is doubled size = ssp.get_figsize(ncols=2) print(f"1×2: {size}") fig, axes = plt.subplots(1, 2, figsize=size) for ax in axes: ax.plot(x, np.sin(x)) axes[0].set(title="Left", xlabel="x") axes[1].set(title="Right", xlabel="x") plt.show() # 1×5 with nmax=2 — width capped at 2× base size size = ssp.get_figsize(ncols=5, nmax=2) print(f"1×5 nmax=2: {size}") fig, axes = plt.subplots(1, 5, figsize=size) for ax in axes: ax.plot(x, np.sin(x)) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.254 seconds) .. _sphx_glr_download__auto_examples_get_figsize.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: get_figsize.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: get_figsize.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: get_figsize.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_