Title: FIX: layout for mixed descent multiline text objects by jklymak · Pull Request #11499 · matplotlib/matplotlib · GitHub
Open Graph Title: FIX: layout for mixed descent multiline text objects by jklymak · Pull Request #11499 · matplotlib/matplotlib
X Title: FIX: layout for mixed descent multiline text objects by jklymak · Pull Request #11499 · matplotlib/matplotlib
Description: PR Summary Closes #11498 partially closes #11468 WIP: this'll fail some tests that depended on the previous bad behaviour... EDIT This indeed failed some tests, but I'd pretty strongly argue the tests were broken and this PR makes them correct... Test: import matplotlib.pyplot as plt import matplotlib.patches as mpatches fig, ax = plt.subplots(constrained_layout=False) ax.set_xlim([0, 1.4]) ax.set_ylim([0, 2]) ax.axhline(0.5, color='C2', linewidth=0.3) sts = ['Line', '2 Lines g\n 2nd Line g', '$\sum_i x $', 'hi $\sum_i x $\ntest', 'test\n $\sum_i x $', '$\sum_i x $\n $\sum_i x $'] for nn, st in enumerate(sts): tt = ax.text(0.2 * nn + 0.1, 0.5, st, horizontalalignment='center', verticalalignment='bottom') bb = tt.get_window_extent(fig.canvas.get_renderer()) bbt = bb.inverse_transformed(ax.transAxes) r = mpatches.Rectangle((0,0), 1, 1, clip_on=False, transform=ax.transAxes) r.set_bounds(bbt.bounds) ax.add_patch(r) ax.text(1.2, 0.5, 'Bottom align', color='C2') if 1: ax.axhline(1.3, color='C2', linewidth=0.3) for nn, st in enumerate(sts): tt = ax.text(0.2 * nn + 0.1, 1.3, st, horizontalalignment='center', verticalalignment='top') bb = tt.get_window_extent(fig.canvas.get_renderer()) bbt = bb.inverse_transformed(ax.transAxes) r = mpatches.Rectangle((0,0), 1, 1, clip_on=False, transform=ax.transAxes) r.set_bounds(bbt.bounds) ax.add_patch(r) ax.text(1.2, 1.3, 'Top align', color='C2') ax.axhline(1.8, color='C2', linewidth=0.3) for nn, st in enumerate(sts): tt = ax.text(0.2 * nn + 0.1, 1.8, st, horizontalalignment='center', verticalalignment='baseline') bb = tt.get_window_extent(fig.canvas.get_renderer()) bbt = bb.inverse_transformed(ax.transAxes) r = mpatches.Rectangle((0,0), 1, 1, clip_on=False, transform=ax.transAxes) r.set_bounds(bbt.bounds) ax.add_patch(r) ax.text(1.2, 1.8, 'Baseline align', color='C2') ax.axhline(0.1, color='C2', linewidth=0.3) for nn, st in enumerate(sts): tt = ax.text(0.2 * nn + 0.1, 0.1, st, horizontalalignment='center', verticalalignment='bottom', rotation=20) bb = tt.get_window_extent(fig.canvas.get_renderer()) bbt = bb.inverse_transformed(ax.transAxes) r = mpatches.Rectangle((0,0), 1, 1, clip_on=False, transform=ax.transAxes) r.set_bounds(bbt.bounds) ax.add_patch(r) ax.text(1.2, 0.1, 'Bot align, rot20', color='C2') bb = tt.get_window_extent(fig.canvas.get_renderer()) bbt = bb.inverse_transformed(ax.transAxes) r = mpatches.Rectangle((0,0), 1, 1, clip_on=False, transform=ax.transAxes) r.set_bounds(bbt.bounds) ax.add_patch(r) fig.savefig('Old.png') plt.show() Before: With PR: PR Checklist FIX baseline alignment for multiline Add blue boxes to test... Has Pytest style unit tests Code is PEP 8 compliant New features are documented, with examples if plot related Documentation is sphinx and numpydoc compliant Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there) Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way
Open Graph Description: PR Summary Closes #11498 partially closes #11468 WIP: this'll fail some tests that depended on the previous bad behaviour... EDIT This indeed failed some tests, but I'd pretty strongly argu...
X Description: PR Summary Closes #11498 partially closes #11468 WIP: this'll fail some tests that depended on the previous bad behaviour... EDIT This indeed failed some tests, but I'd pretty stron...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/11499
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:3cf5383e-369f-53f8-2736-bc935f838071 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BF58:3161F8:37FDF51:4D425F1:6A54BAF9 |
| html-safe-nonce | 288473edfef434caeb75df52aea316d0c84d333b552c2648021b760772030894 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjU4OjMxNjFGODozN0ZERjUxOjRENDI1RjE6NkE1NEJBRjkiLCJ2aXNpdG9yX2lkIjoiNzU3NTg3MTU4NTE3NDk5MzY1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 71042088990b6855a27d41e31cb4ca77ce961b6ee2458aad91d78b666329e54a |
| hovercard-subject-tag | pull_request:196960249 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/11499/files |
| twitter:image | https://avatars.githubusercontent.com/u/1562854?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1562854?s=400&v=4 |
| og:image:alt | PR Summary Closes #11498 partially closes #11468 WIP: this'll fail some tests that depended on the previous bad behaviour... EDIT This indeed failed some tests, but I'd pretty strongly argu... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 69f9664dd5e7a82ba8ab1b4cb7f5a2f09333ab38 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width