You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ENH]: allow scatter plots to preserve data limits. #24416
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 for a particular feature. As far as I understand this is how collections work, which Axes.scatter uses in the background.
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), to plot gridded data with xarray, and geographic data for context with geopandas.
Proposed solution
I 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:
I just stumbled across this. Is there a reason not to expose autolim in scatter? I do not have a use case, but it seems like it would be a simple change that helps geopandas.
Activity
timhoffm commentedon Nov 11, 2022
Related, but stalled: #15595.
rcomer commentedon Dec 7, 2024
I just stumbled across this. Is there a reason not to expose autolim in
scatter? I do not have a use case, but it seems like it would be a simple change that helps geopandas.