Title: [Bug]: set_xlim, set_xbounds being ignored when set_aspect('equal', 'datalim') being used · Issue #28673 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: set_xlim, set_xbounds being ignored when set_aspect('equal', 'datalim') being used · Issue #28673 · matplotlib/matplotlib
X Title: [Bug]: set_xlim, set_xbounds being ignored when set_aspect('equal', 'datalim') being used · Issue #28673 · matplotlib/matplotlib
Description: Bug summary When ax.set_aspect('equal', 'datalim') is used, proceeding ax.set_xbound() or ax.set_xlim() calls being ignored Code to reproduce the error import matplotlib.pyplot as plt import numpy as np # Generate some random data x = np...
Open Graph Description: Bug summary When ax.set_aspect('equal', 'datalim') is used, proceeding ax.set_xbound() or ax.set_xlim() calls being ignored Code to reproduce the error import matplotlib.pyplot as plt import numpy ...
X Description: Bug summary When ax.set_aspect('equal', 'datalim') is used, proceeding ax.set_xbound() or ax.set_xlim() calls being ignored Code to reproduce the error import matplotlib.pyplot as p...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28673
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: set_xlim, set_xbounds being ignored when set_aspect('equal', 'datalim') being used","articleBody":"### Bug summary\r\n\r\nWhen ax.set_aspect('equal', 'datalim') is used, proceeding ax.set_xbound() or ax.set_xlim() calls being ignored\r\n\r\n### Code to reproduce the error\r\n\r\n```Python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\n# Generate some random data\r\nx = np.arange(0, 10, 0.1)\r\ny = np.random.randn(len(x))\r\n\r\n# Create a plot\r\nfig, ax = plt.subplots()\r\nplt.ion()\r\nax.set_aspect('equal', 'datalim')\r\n\r\n\r\n# Set x-axis limits\r\nax.set_xlim(2, 5)\r\n\r\n\r\n# Print the x and y limits\r\nprint(f\"x-axis limits before plotting: {ax.get_xlim()}\")\r\nprint(f\"y-axis limits before plotting: {ax.get_ylim()}\")\r\n\r\nax.plot(x, y*10)\r\n\r\n\r\n# Print the x and y limits\r\nprint(f\"x-axis limits after plotting: {ax.get_xlim()}\")\r\nprint(f\"y-axis limits after plotting: {ax.get_ylim()}\")\r\n\r\n# Set x-axis limits\r\nax.set_xbound(lower=2, upper=5)\r\n# ax.set_xlim(2, 5)\r\n\r\n# Print the x and y limits\r\nprint(f\"x-axis limits after setting xlim: {ax.get_xlim()}\")\r\nprint(f\"y-axis limits after setting xlim: {ax.get_ylim()}\")\r\n\r\n# Show the plot\r\nplt.show()\r\n```\r\nWhat is been tried to mitigate the issue\r\nax._autoscaleXon = False\r\n\r\n\r\n\r\n### Actual outcome\r\n\r\nThis code produces a plot with x-axis not limited to the given xrange 2-5.\r\n\r\n\r\n\r\n\r\n### Expected outcome\r\n\r\nxlimit obeys the given range, with y range automatically adjusted to the given aspect ratio\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\nwindows\r\n\r\n### Matplotlib Version\r\n\r\n3.8.2\r\n\r\n### Matplotlib Backend\r\n\r\nQtAgg\r\n\r\n### Python version\r\n\r\nPython 3.9.7\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\npip","author":{"url":"https://github.com/kjayawar","@type":"Person","name":"kjayawar"},"datePublished":"2024-08-07T11:08:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/28673/matplotlib/issues/28673"}
| 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:4fdf7664-43c8-e228-559b-39707bce4e1f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A140:263D22:1F6079:288774:6A522857 |
| html-safe-nonce | 949bd122725a24d0228ade7802f87323d6dae83eb7e8f1b5af798a0c3c9c160d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTQwOjI2M0QyMjoxRjYwNzk6Mjg4Nzc0OjZBNTIyODU3IiwidmlzaXRvcl9pZCI6IjMzNjMwNTM0NjcyMjA0NTM0NjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2903bd6d7fd87a8c397a26660381d087d6c23d6e73685498190a2ef4fa264961 |
| hovercard-subject-tag | issue:2453213355 |
| 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/28673/issue_layout |
| twitter:image | https://opengraph.githubassets.com/89d164569b03edb98feb91159bff0bce3e91844d9cdd4de4cb0dd7854e5022c9/matplotlib/matplotlib/issues/28673 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/89d164569b03edb98feb91159bff0bce3e91844d9cdd4de4cb0dd7854e5022c9/matplotlib/matplotlib/issues/28673 |
| og:image:alt | Bug summary When ax.set_aspect('equal', 'datalim') is used, proceeding ax.set_xbound() or ax.set_xlim() calls being ignored Code to reproduce the error import matplotlib.pyplot as plt import numpy ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kjayawar |
| 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