Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_basemap: keep original axis limits of figure #38

Merged
merged 2 commits into from
Jul 12, 2019

Conversation

jorisvandenbossche
Copy link
Member

@jorisvandenbossche jorisvandenbossche commented Jul 21, 2018

Opening this for discussion: in my original implementation (http://geopandas.readthedocs.io/en/latest/gallery/plotting_basemap_background.html#contextily-helper-function) I reset the axis limits to the original ones when the ax is passed to the function.

One reason to do this: the extent of the figure does not depend on the zoom level (on how many tiles are merged).

Closes https://github.com/darribas/contextily/issues/45

@coveralls
Copy link

coveralls commented Jul 21, 2018

Coverage Status

Coverage increased (+0.04%) to 90.535% when pulling d7cb4c0 on jorisvandenbossche:add_basemap-restore-axis into cb7a4a0 on darribas:master.

@darribas
Copy link
Collaborator

Nice! so, just to make sure I get it correctly, this PR will make sure the extent of the plot will stay that of the original plot, not that of the pulled down full image, right?

@jorisvandenbossche
Copy link
Member Author

Yes, that is correct

@jorisvandenbossche
Copy link
Member Author

(will add a test if you approve the change)

@darribas
Copy link
Collaborator

Yes, I think this makes sense. Quick question, would this also apply to the case where url is a local file?

@jorisvandenbossche
Copy link
Member Author

Updated the PR to fix merge conflicts.

Yes, I think this makes sense. Quick question, would this also apply to the case where url is a local file?

For now, I didn't make any distinction between both.

And I also updated the test

@darribas
Copy link
Collaborator

darribas commented Jan 5, 2019

Cool. One more thing, could you please add the option of reset_extent as mentioned in #45? I think you're right it makes more sense to set the default to True, but it I think in some contexts (particularly when url points to a local file), the user might be interested in letting the extent be reset by the addition.

@@ -92,8 +93,12 @@ def add_basemap(ax, zoom=ZOOM, url=sources.ST_TERRAIN,
# Plotting
ax.imshow(image, extent=extent,
interpolation=interpolation, **extra_imshow_args)

ax.axis((xmin, xmax, ymin, ymax))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think giving the option should just be adding here:

if reset_extent:
     ax.axis(...)

@darribas
Copy link
Collaborator

@jorisvandenbossche I've cleaned conflicts in one of the tests with current master and added the option to reset the extent (as opposed of always doing it) into a PR to your branch. If you merge that one, I'm happy to merge this too into master.

@darribas
Copy link
Collaborator

Whoops, looks like this introduces errors on the tests now...

https://travis-ci.org/darribas/contextily/jobs/522345969

These are in addition to the 3.5 issue and come up in 3.6. Would you mind having a look into it @jorisvandenbossche?

@ljwolf ljwolf merged commit 65c5b72 into geopandas:master Jul 12, 2019
@jorisvandenbossche jorisvandenbossche deleted the add_basemap-restore-axis branch July 12, 2019 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding option to restrict ax extent to original one when using add_basemap
4 participants