Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Align titles #22376#25591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Align titles #22376#25591
Changes from10 commits
d1067a6e84960dd6d5d7f065d9927f5220a838ace39decc20e8042f852164fab44fb0037412394eb53e6938d9e51fe094aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -11,6 +11,7 @@ | ||
| import numpy as np | ||
| import pytest | ||
| from PIL import Image | ||
| from matplotlib.testing.compare import compare_images | ||
| import matplotlib as mpl | ||
| from matplotlib import gridspec | ||
| @@ -102,6 +103,38 @@ def test_align_labels_stray_axes(): | ||
| np.testing.assert_allclose(yn[::2], yn[1::2]) | ||
| ## TODO add image comparison | ||
| def test_align_titles(): | ||
| fig, axs = plt.subplots(2, 2, | ||
| subplot_kw={"xlabel": "x", "ylabel": "", | ||
| "title": "Title"}) | ||
| axs[0][0].imshow(plt.np.zeros((5, 3))) | ||
| axs[0][1].imshow(plt.np.zeros((3, 5))) | ||
| axs[1][0].imshow(plt.np.zeros((2, 1))) | ||
| axs[1][1].imshow(plt.np.zeros((1, 2))) | ||
| axs[0][1].set_title('Title2', loc="left") | ||
| fig.align_titles() | ||
| fig.savefig("./result_images/test_figure/figure_align_titles") | ||
| compare_images("./lib/matplotlib/tests/baseline_images/figure_align_titles.png", | ||
| ||
| "./result_images/test_figure/figure_align_titles.png", 0) | ||
| ## TODO add image comparison | ||
| @image_comparison(['figure_align_titles_param'], extensions=['png', 'svg'], | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The test failures that are directly related to this PR are due to the baseline images for this image comparison not being added to the repo If it is passing locally, those two files (png, svg) should be added in the | ||
| tol=0 if platform.machine() == 'x86_64' else 0.01) | ||
| def test_align_titles_param(): | ||
| fig, axs = plt.subplots(2, 2, | ||
| subplot_kw={"xlabel": "x", "ylabel": "", | ||
| "title": "t"}) | ||
| axs[0][0].imshow(plt.np.zeros((3, 5))) | ||
| axs[0][1].imshow(plt.np.zeros((5, 3))) | ||
| axs[1][0].imshow(plt.np.zeros((2, 1))) | ||
| axs[1][1].imshow(plt.np.zeros((1, 2))) | ||
| fig.align_titles([axs[0][0], axs[0][1]]) | ||
| def test_figure_label(): | ||
| # pyplot figure creation, selection, and closing with label/number/instance | ||
| plt.close('all') | ||