Title: Weird behaviour of suptitle() when horizontalalignment is not 'center' · Issue #12197 · matplotlib/matplotlib · GitHub
Open Graph Title: Weird behaviour of suptitle() when horizontalalignment is not 'center' · Issue #12197 · matplotlib/matplotlib
X Title: Weird behaviour of suptitle() when horizontalalignment is not 'center' · Issue #12197 · matplotlib/matplotlib
Description: Bug report Bug summary horizontalalignment = 'left' aligns the title on the right, horizontalalignment = 'right' aligns a short title on the left, horizontalalignment = 'right' displaces a longer title on the far left Code for reproducti...
Open Graph Description: Bug report Bug summary horizontalalignment = 'left' aligns the title on the right, horizontalalignment = 'right' aligns a short title on the left, horizontalalignment = 'right' displaces a longer t...
X Description: Bug report Bug summary horizontalalignment = 'left' aligns the title on the right, horizontalalignment = 'right' aligns a short title on the left, horizontalalignment = 'right...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/12197
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Weird behaviour of suptitle() when horizontalalignment is not 'center'","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\n`horizontalalignment = 'left'` aligns the title on the right, `horizontalalignment = 'right'` aligns a short title on the left, `horizontalalignment = 'right'` displaces a longer title on the far left\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required--\u003e\r\n\r\n```python\r\n# Left alignment test, short title\r\nfig = plt.figure(figsize=(9,4))\r\nax = fig.add_subplot(111)\r\nfig.suptitle('This figure suptitle should be on the left', horizontalalignment = 'left')\r\nax.set_title('This axis title should be on the left', loc='left');\r\nfig.savefig('left_align.png')\r\n\r\n# Right alignment test, short title\r\nfig = plt.figure(figsize=(9,4))\r\nax = fig.add_subplot(111)\r\nfig.suptitle('This figure suptitle should be on the right', horizontalalignment = 'right')\r\nax.set_title('This axis title should be on the right', loc='right');\r\nfig.savefig('right_align.png')\r\n\r\n# Right alignment test, longer title\r\nfig = plt.figure(figsize=(9,4))\r\nax = fig.add_subplot(111)\r\nfig.suptitle('This figure suptitle should be on the right but it is far left', horizontalalignment = 'right')\r\nax.set_title('This axis title should be on the left', loc='left')\r\nfig.savefig('far_left.png');\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n* Left alignment test, short title\r\n\r\n\r\n* Right alignment test, short title\r\n\r\n\r\n* Right alignment test, longer title\r\n\r\n\r\n**Expected outcome**\r\n\r\nThe following code manually sets the figure title at the expected position:\r\n\r\n```python\r\nfig = plt.figure(figsize=(9,4))\r\nax = fig.add_subplot(111)\r\nfig.suptitle('This figure suptitle is long but it is manually positioned', x = 0.38)\r\nax.set_title('This axis title should be on the left', loc='left')\r\nfig.savefig('manual_pos.png');\r\n```\r\nWhich gives:\r\n\r\n\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: Windows\r\n * Matplotlib version: 2.1.2 and 2.2.3\r\n * Matplotlib backend: agg\r\n * Python version: 3.6.4\r\n * Jupyter version: 4.4.0\r\n","author":{"url":"https://github.com/gansanay","@type":"Person","name":"gansanay"},"datePublished":"2018-09-21T09:13:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/12197/matplotlib/issues/12197"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:480ce967-91e7-2ac8-fd39-7043662d8251 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 989E:C218B:19A61BE:235AFA3:6A5731EA |
| html-safe-nonce | d710d9f6e5a9196f22cf1c8dd037a0bc5f65162e1ed84d723c653def17a1c6e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODlFOkMyMThCOjE5QTYxQkU6MjM1QUZBMzo2QTU3MzFFQSIsInZpc2l0b3JfaWQiOiI1NzgzMzI3ODE4MzgyNzgyOTU0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a4d661ab917402ad970625c11264cf317a87385eb18dbc0cfb614c5750d1e40b |
| hovercard-subject-tag | issue:362524399 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/matplotlib/matplotlib/12197/issue_layout |
| twitter:image | https://opengraph.githubassets.com/965391bffc4023ca2282811ffdf87901ebd1187bf02c064a3dc716bbb80c1958/matplotlib/matplotlib/issues/12197 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/965391bffc4023ca2282811ffdf87901ebd1187bf02c064a3dc716bbb80c1958/matplotlib/matplotlib/issues/12197 |
| og:image:alt | Bug report Bug summary horizontalalignment = 'left' aligns the title on the right, horizontalalignment = 'right' aligns a short title on the left, horizontalalignment = 'right' displaces a longer t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gansanay |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2576d1f0198cf1588faf2edf27f1ed120903be10 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width