Title: savefig with bbox_inches='tight' ignores annotation without text · Issue #3816 · matplotlib/matplotlib · GitHub
Open Graph Title: savefig with bbox_inches='tight' ignores annotation without text · Issue #3816 · matplotlib/matplotlib
X Title: savefig with bbox_inches='tight' ignores annotation without text · Issue #3816 · matplotlib/matplotlib
Description: It appears that the bbox_inches='tight' option in savefig ignores annotations without text. Here is my example code import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_axes([0.2, 0.2, 0.6, 0.6]) arrow1 = ax.annotate('text', x...
Open Graph Description: It appears that the bbox_inches='tight' option in savefig ignores annotations without text. Here is my example code import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_axes([0.2, 0.2, 0...
X Description: It appears that the bbox_inches='tight' option in savefig ignores annotations without text. Here is my example code import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_axes([0.2...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/3816
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"savefig with bbox_inches='tight' ignores annotation without text","articleBody":"It appears that the bbox_inches='tight' option in savefig ignores annotations without text. Here is my example code\n\n```\nimport matplotlib.pyplot as plt\n\nfig = plt.figure()\nax = fig.add_axes([0.2, 0.2, 0.6, 0.6])\narrow1 = ax.annotate('text', xy = [0.5,-0.2], xycoords = 'axes fraction', \\\n xytext = [-72,0], textcoords = 'offset points', \\\n arrowprops = dict(arrowstyle = '-|\u003e', mutation_scale = 10.0, \\\n shrinkA = 0, shrinkB = 0, linewidth = 1))\narrow2 = ax.annotate('', xy = [0.5,1.2], xycoords = 'axes fraction', \\\n xytext = [-72,0], textcoords = 'offset points', \\\n arrowprops = dict(arrowstyle = '-|\u003e', mutation_scale = 10.0, \\\n shrinkA = 0, shrinkB = 0, linewidth = 1))\nfig.savefig('test.png')\nfig.savefig('test-tight.png', bbox_inches = 'tight')\n```\n\nHere is test.png, showing that I have two annotations. One annotation, with text, below the axes and one annotation, without text, above the axes.\n\n\n\nHere is test-tight.png, showing only one annotation. The annotation above the axes, without the text, has been ignored.\n\n\n\nLooking in the source code, `bbox_inches='tight'` attempts to find the size and location of artists by calling `artist.get_window_extent()`. When I try `arrow1.get_window_extent()`, I get a bounding box that appears to correspond to the text. When I try `arrow2.get_window_extent()`, I get a bounding box with zero height and zero width. Thus, the root of the problem is `.get_window_extent()` doesn't include the arrow.\n\nAny ideas for how to get around this, in a reasonably robust manner? If I could somehow get the proper bounding box for the whole annotation, then I would be in business. However, I can't even seem to get the line or patch objects out of arrow2.\n\nIn case it matters, I am on matplotlib 1.4.0, Python 2.7.6, and Mac OS X 10.8.5\n","author":{"url":"https://github.com/breedlun","@type":"Person","name":"breedlun"},"datePublished":"2014-11-19T14:04:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/3816/matplotlib/issues/3816"}
| 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:fc0a533b-aad3-9bc8-ff5e-aade04331412 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A862:1F08C5:47FBC2D:645CB78:6A54EB8F |
| html-safe-nonce | ed9c888e134dd768e3fcba59e6d84bc37ad269206c4323e829d92dae9f088b3d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODYyOjFGMDhDNTo0N0ZCQzJEOjY0NUNCNzg6NkE1NEVCOEYiLCJ2aXNpdG9yX2lkIjoiODA1NzEzNTQ5ODYzNDgwMjA3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 01b1bfd498a380784d77299ce14ca00ff024250c64c72d4ccf463f9cc46d7f2e |
| hovercard-subject-tag | issue:49394909 |
| 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/3816/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7bc3ee889f5f667b9522603c5654f74553ea49b40da0d7c020079198e4d5222e/matplotlib/matplotlib/issues/3816 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7bc3ee889f5f667b9522603c5654f74553ea49b40da0d7c020079198e4d5222e/matplotlib/matplotlib/issues/3816 |
| og:image:alt | It appears that the bbox_inches='tight' option in savefig ignores annotations without text. Here is my example code import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_axes([0.2, 0.2, 0... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | breedlun |
| hostname | github.com |
| expected-hostname | github.com |
| None | eae2aab99907699a22d2c8449aa683ca74454fca87211b98f7c7b722086b2839 |
| 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 | bb1b4ffdc07c66de20ad344214f55df0aa364bd3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width