Title: Alignment of labels incorrect if fontsize<1pt PDF backend · Issue #9963 · matplotlib/matplotlib · GitHub
Open Graph Title: Alignment of labels incorrect if fontsize<1pt PDF backend · Issue #9963 · matplotlib/matplotlib
X Title: Alignment of labels incorrect if fontsize<1pt PDF backend · Issue #9963 · matplotlib/matplotlib
Description: Label padding around the axes depends on the length of the label when figure is saved as pdf. The below code creates a figure and adds labels of different length. Those labels are not well aligned in the saved pdf version. Instead their ...
Open Graph Description: Label padding around the axes depends on the length of the label when figure is saved as pdf. The below code creates a figure and adds labels of different length. Those labels are not well aligned ...
X Description: Label padding around the axes depends on the length of the label when figure is saved as pdf. The below code creates a figure and adds labels of different length. Those labels are not well aligned ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/9963
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Alignment of labels incorrect if fontsize\u003c1pt PDF backend","articleBody":"Label padding around the axes depends on the length of the label when figure is saved as pdf. \r\n\r\nThe below code creates a figure and adds labels of different length. Those labels are not well aligned in the saved pdf version. Instead their padding towards the axes is depending on how many characters the label has. This issue is the more pronounced the larger the dpi (at constant figsize*dpi product).\r\n\r\nThe png files saved do not show this unexpected behaviour; all labels are aligned correctly. The expected output when saving the pdf file is of course the same as the png.\r\n\r\n```\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib.ticker as ticker\r\nimport numpy as np\r\n\r\na = np.random.rand(5,5)\r\n\r\nfor i in [1,1.25,1.5]:\r\n\r\n plt.rcParams[\"axes.linewidth\"] = i*0.1\r\n fig = plt.figure(figsize=(i,i), dpi=int(500./i))\r\n fig.subplots_adjust(0.44,0.44,0.56,0.56)\r\n ax = fig.add_subplot(111)\r\n ax.imshow(a)\r\n ax.set_title(\"figsize {}, dpi {}\".format((i,i), int(500./i)), size=i)\r\n \r\n ax.set_yticklabels([\"\",1,10,100, \"ABCDEFGH\", \"X\"])\r\n ax.set_xticklabels([\"\",1,10,100, \"long long label\", \"short\"])\r\n ax.xaxis.set_major_locator(ticker.MultipleLocator(1))\r\n ax.yaxis.set_major_locator(ticker.MultipleLocator(1))\r\n \r\n ax.tick_params(axis='both', which='both', labelsize=i*0.5, length=i*0.5, width=i*0.05)\r\n ax.tick_params(axis='x',which='both', rotation=90)\r\n\r\n plt.savefig(\"fig_f{}.pdf\".format(i))\r\n plt.savefig(\"fig_f{}.png\".format(i))\r\nplt.show()\r\n```\r\n\r\n\r\n\r\n[reproduced with python 2.7, matplotlib 2.1, Qt4Agg backend as well as TkAgg backend]\r\n\r\n*This issue was initially brought up in [this Stackoverflow question](https://stackoverflow.com/questions/47718341/matplotlib-imshow-issues-title-on-top-of-top-xlabels-and-ylabels-not-aligned).*\r\n","author":{"url":"https://github.com/ImportanceOfBeingErnest","@type":"Person","name":"ImportanceOfBeingErnest"},"datePublished":"2017-12-08T23:33:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":29},"url":"https://github.com/9963/matplotlib/issues/9963"}
| 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:fd31d882-cfc9-0c36-7906-58cd71b9aabf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 81CA:2F08ED:1264223:192421B:6A55C7B3 |
| html-safe-nonce | 33f4a8831fcb85fafbca2e9fbcaf4044fec0360fa48cff7ec434ef405b3ab9b7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MUNBOjJGMDhFRDoxMjY0MjIzOjE5MjQyMUI6NkE1NUM3QjMiLCJ2aXNpdG9yX2lkIjoiODY4MzQzMDExMzM1Mjk5MjY5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ae6208292a7f5d7a7e15d1b7cabbf2524216eed789a08d211f64b94cce7439a0 |
| hovercard-subject-tag | issue:280647942 |
| 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/9963/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f599acf22527c0dc2645f4e7634849d1021ae1bd4178462907a2e1780754881e/matplotlib/matplotlib/issues/9963 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f599acf22527c0dc2645f4e7634849d1021ae1bd4178462907a2e1780754881e/matplotlib/matplotlib/issues/9963 |
| og:image:alt | Label padding around the axes depends on the length of the label when figure is saved as pdf. The below code creates a figure and adds labels of different length. Those labels are not well aligned ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ImportanceOfBeingErnest |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 8f8e1726192df8dce16872ceb503336c12e9ae78 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width