basemap icon indicating copy to clipboard operation
basemap copied to clipboard

Cropped world map outline with 1.1.0

Open xflr6 opened this issue 7 years ago • 4 comments

Compare 1.0.8: shot1

with 1.1.0 (slightly cropped top, left, right and bottom): shot2

Both from http://www.lfd.uci.edu/~gohlke/pythonlibs/#basemap

xflr6 avatar Mar 02 '17 06:03 xflr6

Yes, this is an unfortunate side-effect of another bugfix. I have not yet figured out how to fix it, or some sort of work-around. Essentially, we now have a _clip_limbs() method that does proper clipping of the map limbs so that panning and zooming does not result in the map appearing outside the plot region. Unfortunately, the maps are displayed to the maximum extent possible in the plot area. Either I need to make the clipping bounding box ever so slightly larger (somehow), or make the maps ever so slightly smaller (somehow)...

On Thu, Mar 2, 2017 at 1:38 AM, Sebastian Bank [email protected] wrote:

Compare 1.0.8: [image: shot1] https://cloud.githubusercontent.com/assets/6342379/23495802/0241992a-ff1b-11e6-90af-d36529997d09.png

with 1.1.0 (slightly cropped top, left, right and bottom): [image: shot2] https://cloud.githubusercontent.com/assets/6342379/23495818/149a978e-ff1b-11e6-9dd1-db47cfb5c405.png

Both from http://www.lfd.uci.edu/~gohlke/pythonlibs/#basemap

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matplotlib/basemap/issues/344, or mute the thread https://github.com/notifications/unsubscribe-auth/AARy-IhVMNQQZUzgREDP44xaJC1kACryks5rhmPbgaJpZM4MQm8I .

WeatherGod avatar Mar 03 '17 17:03 WeatherGod

Was this problem ever addressed? I am examining some very aged Python code in preparation for a server upgrade, and this map border clipping issue is showing up when we make maps using basemap 1.4.1 on a testbed machine.

rschmunk avatar Apr 09 '24 01:04 rschmunk

@rschmunk The problem is still there, as you could observe. One possible workaround at the moment is to revert the clipping:

bmap = Basemap(...)
background = bmap.drawmapboundary(fill_color=oceancolor, linewidth=0)
background.set_clip_on(False)

As a side effect, when you draw data afterwards, it may happen that the drawn data goes on top of the map boundary if these data are too close to the boundary (because the zorder of the background and map boundary is set to 0 if I remember correctly). What I currently do to workaround it is to create a copy of the background and in this copy I increase the zorder and remove the fill color:

borders = copy.copy(background)
borders.set_zorder(3)
borders.set_facecolor("none")
bmap.ax.add_artist(borders)

What this really shows is that there is a design problem with Basemap.drawmapboundary, because there is one single Artist providing the map background and the map border with competing needs. The map background needs a zorder of 0 and should also be used to clip the contents drawn in the map. The map border needs a zorder as high as possible and should not be clipped. The solution in basemap should be that map background and map border are treated as separate things.

molinav avatar Apr 24 '24 08:04 molinav

@molinav,Calling background.set_clip_on(False) right after drawing the map boundary seems to solve the problem for our situation. There's no problem with later drawing, as the only bit remaining to be done is adding a colorbar to the bottom of the plot.

This definitely beats applying an ugly kludge like drawing a parallel at 89.5°.

TYVM.

rschmunk avatar Apr 24 '24 22:04 rschmunk