Title: [ENH]: allow scatter plots to preserve data limits. · Issue #24416 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: allow scatter plots to preserve data limits. · Issue #24416 · matplotlib/matplotlib
X Title: [ENH]: allow scatter plots to preserve data limits. · Issue #24416 · matplotlib/matplotlib
Description: Problem I would like to plot scatter points as contextual data while preserving the current axes data limits. Something like this can be achieved with Axes.set_autoscale(False), but I would like to keep auto-scaling on, and disable it fo...
Open Graph Description: Problem I would like to plot scatter points as contextual data while preserving the current axes data limits. Something like this can be achieved with Axes.set_autoscale(False), but I would like to...
X Description: Problem I would like to plot scatter points as contextual data while preserving the current axes data limits. Something like this can be achieved with Axes.set_autoscale(False), but I would like to...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/24416
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: allow scatter plots to preserve data limits.","articleBody":"### Problem\n\nI would like to plot scatter points as contextual data while preserving the current axes data limits. Something like this can be achieved with `Axes.set_autoscale(False)`, but I would like to keep auto-scaling on, and disable it for a particular feature. As far as I understand this is how collections work, which `Axes.scatter` uses in the background.\r\n\r\n**Context:** this feature will allow GeoPandas to consistently plot line, polygon (using `add_collection()`) and point data (using `scatter()`) as contextual data not affecting axes limits (see geopandas/geopandas#2602). Down the line it will benefit a small library I am developing ([hyoga](https://hyoga.readthedocs.io)), to plot gridded data with xarray, and geographic data for context with geopandas.\n\n### Proposed solution\n\nI noticed that `add_collection` has an `autolim` keyword that defaults to `True`. As opposed to completely disabling auto-scaling, setting `autolim=False` simply skips updating the axes data limits for this particular collection, meaning auto-scaling stays on, but ignores it (if I read this correctly). I propose to propagate the `autolim` keyword argument to `Axes.scatter` and pass it to `add_collection` here:\r\n\r\nhttps://github.com/matplotlib/matplotlib/blob/9d8fde258d66168f20800155af614c8ca0bb8e24/lib/matplotlib/axes/_axes.py#L4680-L4681\r\n\r\nThis would allow something like:\r\n\r\n```python\r\nax.scatter(x_subject, y_subject) # default to autolim=True, update limits\r\nax.scatter(x_context, y_context, autolim=False) # don't update limits\r\nax.plot(something_else) # update limits disregarding {x,y}_context\r\n```\r\nI am happy to open a PR if this makes sense.","author":{"url":"https://github.com/juseg","@type":"Person","name":"juseg"},"datePublished":"2022-11-10T10:36:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/24416/matplotlib/issues/24416"}
| 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:ee799ea0-a692-1acd-0b28-d02f7ce6b341 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E99E:2FB335:168019F:1E05A1F:6A52BAD1 |
| html-safe-nonce | ea38ef057e59e0ff7e2797829c581d85ab40756e3a7192daa457ccfca120cbcc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTlFOjJGQjMzNToxNjgwMTlGOjFFMDVBMUY6NkE1MkJBRDEiLCJ2aXNpdG9yX2lkIjoiNTc4Mzk2MDIwOTM2NzE1MzM2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2997f5ad258217bd1871152d7a009f20a9685dd965e82c7cafd36c4fbc960566 |
| hovercard-subject-tag | issue:1443650407 |
| 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/24416/issue_layout |
| twitter:image | https://opengraph.githubassets.com/54b3a7e62eceed58987b87b5a5ee557ba1fba40c4773c66c2b800472babc2057/matplotlib/matplotlib/issues/24416 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/54b3a7e62eceed58987b87b5a5ee557ba1fba40c4773c66c2b800472babc2057/matplotlib/matplotlib/issues/24416 |
| og:image:alt | Problem I would like to plot scatter points as contextual data while preserving the current axes data limits. Something like this can be achieved with Axes.set_autoscale(False), but I would like to... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | juseg |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width