Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > bf21b4394f4d7fa09e3626145d3315e0 > files > 231

python-matplotlib-doc-1.2.0-14.fc18.i686.rpm

.. _misc-tight_bbox_test:

misc example code: tight_bbox_test.py
=====================================

[`source code <tight_bbox_test.py>`_]

::

    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()
    

Keywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)