Title: [Bug]: bbox_inches='tight' works differently when ax.plot() have markers · Issue #30695 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: bbox_inches='tight' works differently when ax.plot() have markers · Issue #30695 · matplotlib/matplotlib
X Title: [Bug]: bbox_inches='tight' works differently when ax.plot() have markers · Issue #30695 · matplotlib/matplotlib
Description: Bug summary Hello. This is a minimal code: # type: ignore import matplotlib.pyplot as plt from matplotlib.transforms import Affine2D, ScaledTranslation, BlendedGenericTransform L = 755 fig, axes = plt.subplots(nrows=3, ncols=1, dpi=150) ...
Open Graph Description: Bug summary Hello. This is a minimal code: # type: ignore import matplotlib.pyplot as plt from matplotlib.transforms import Affine2D, ScaledTranslation, BlendedGenericTransform L = 755 fig, axes = ...
X Description: Bug summary Hello. This is a minimal code: # type: ignore import matplotlib.pyplot as plt from matplotlib.transforms import Affine2D, ScaledTranslation, BlendedGenericTransform L = 755 fig, axes = ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30695
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: bbox_inches='tight' works differently when ax.plot() have markers","articleBody":"### Bug summary\n\nHello.\n\nThis is a minimal code:\n\n```python\n# type: ignore\n\nimport matplotlib.pyplot as plt\nfrom matplotlib.transforms import Affine2D, ScaledTranslation, BlendedGenericTransform\n\nL = 755\n\nfig, axes = plt.subplots(nrows=3, ncols=1, dpi=150)\n\nfor ax in axes:\n ax.margins(x=0)\n ax.set_xlim((0, L))\n\nax = axes[-1]\n\ntr = BlendedGenericTransform(\n x_transform=ax.transData,\n y_transform=ax.transAxes + ScaledTranslation(0, -355, Affine2D())\n)\n\nax.plot(\n [0, L],\n [0, 0],\n lw=1.4,\n c='black',\n clip_on=False,\n transform=tr,\n marker='o', # \u003c--- (1)\n markersize=3, # \u003c--- (2)\n zorder=10\n)\n\nplt.show()\n```\n\nI run this in VS Code Notebook (`%config InlineBackend.print_figure_kwargs = {'bbox_inches':'tight'}`), and this code produces image I expected:\n\n\u003cimg width=\"855\" height=\"950\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/d330c35e-1fd4-4efb-96e7-ba75b385c277\" /\u003e\n\nFigure sizes are changed automatically so we see horizontal line at the bottom of this figure.\n\nThen I make a small change for `ax.plot`: I comment `marker=...` and `markersize=...` ((1) and (2) in code above). After that small change figure stop to include horizontal line:\n\n\u003cimg width=\"852\" height=\"626\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/14f98278-1317-401e-9953-a00452016da0\" /\u003e\n\nNot sure, if it is a bug, but this is definitelly very strange.\n\n### Code for reproduction\n\n```Python\n# type: ignore\n\nimport matplotlib.pyplot as plt\nfrom matplotlib.transforms import Affine2D, ScaledTranslation, BlendedGenericTransform\n\nL = 755\n\nfig, axes = plt.subplots(nrows=3, ncols=1, dpi=150)\n\nfor ax in axes:\n ax.margins(x=0)\n ax.set_xlim((0, L))\n\nax = axes[-1]\n\ntr = BlendedGenericTransform(\n x_transform=ax.transData,\n y_transform=ax.transAxes + ScaledTranslation(0, -355, Affine2D())\n)\n\nax.plot(\n [0, L],\n [0, 0],\n lw=1.4,\n c='black',\n clip_on=False,\n transform=tr,\n # marker='o', # \u003c--- comment this line to make line outside figure boundaries\n # markersize=3, # \u003c--- comment this line to make line outside figure boundaries\n zorder=10\n)\n\nplt.show()\n```\n\n### Actual outcome\n\nWhen I comment `marker=...` and `markersize=...` in `ax.plot(...)`, horizontal line is out of figure boundaries.\n\n\u003cimg width=\"852\" height=\"626\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/14f98278-1317-401e-9953-a00452016da0\" /\u003e\n\n### Expected outcome\n\nI expect figure changes its sizes to include horizontal line as shown below:\n\n\u003cimg width=\"855\" height=\"950\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/d330c35e-1fd4-4efb-96e7-ba75b385c277\" /\u003e\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nWindows 10\n\n### Matplotlib Version\n\n3.10.7\n\n### Matplotlib Backend\n\n'module://matplotlib_inline.backend_inline'\n\n### Python version\n\n3.13.7\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/sindzicat","@type":"Person","name":"sindzicat"},"datePublished":"2025-10-28T09:55:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/30695/matplotlib/issues/30695"}
| 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:43dcb65e-e7a2-b1f7-ac3d-0fe731ea7b75 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D8E:1111EE:1B9A5F3:258985C:6A5247AC |
| html-safe-nonce | c430fe86342b5418dae4a7db91b18d5cdf671d88ec883b664f07757d7c1df3a0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDhFOjExMTFFRToxQjlBNUYzOjI1ODk4NUM6NkE1MjQ3QUMiLCJ2aXNpdG9yX2lkIjoiNzQyNjQ1MzY5NzMzMTM0OTQyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a371a3f2662a114819b8cebb57e67a2fa5058e744b87954353d35f361f0d2c1c |
| hovercard-subject-tag | issue:3560687838 |
| 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/30695/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f4c5419ee43a077c68ce4810be93542002a3e125cda0191caac1a558d0efb930/matplotlib/matplotlib/issues/30695 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f4c5419ee43a077c68ce4810be93542002a3e125cda0191caac1a558d0efb930/matplotlib/matplotlib/issues/30695 |
| og:image:alt | Bug summary Hello. This is a minimal code: # type: ignore import matplotlib.pyplot as plt from matplotlib.transforms import Affine2D, ScaledTranslation, BlendedGenericTransform L = 755 fig, axes = ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sindzicat |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width