.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_misc_tight_bbox_test.py: =============== Tight Bbox Test =============== .. image:: /gallery/misc/images/sphx_glr_tight_bbox_test_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none saving tight_bbox_test.png saving tight_bbox_test.pdf saving tight_bbox_test.svg saving tight_bbox_test.svgz saving tight_bbox_test.eps | .. code-block:: python from __future__ import print_function import matplotlib.pyplot as plt import numpy as np ax = plt.axes([0.1, 0.3, 0.5, 0.5]) ax.pcolormesh(np.array([[1, 2], [3, 4]])) plt.yticks([0.5, 1.5], ["long long tick label", "tick label"]) plt.ylabel("My y-label") plt.title("Check saved figures for their bboxes") for ext in ["png", "pdf", "svg", "svgz", "eps"]: print("saving tight_bbox_test.%s" % (ext,)) plt.savefig("tight_bbox_test.%s" % (ext,), bbox_inches="tight") plt.show() .. _sphx_glr_download_gallery_misc_tight_bbox_test.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: tight_bbox_test.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: tight_bbox_test.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature Keywords: matplotlib code example, codex, python plot, pyplot `Gallery generated by Sphinx-Gallery `_