You are reading an old version of the documentation (v3.0.2). For the latest version see
Version 3.0.2
Fork me on GitHub

Related Topics

Tight Bbox TestΒΆ



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

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

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery