Reputation: 194
I'm struggling with round stereographic plots using the matplotlib basemap toolkit. I always get a cropped map boundary at the top, bottom and left, right. The example code:
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
m = Basemap(projection='spstere', boundinglat=-60, lon_0=180,
lat_ts=-71, round=True, ellps='WGS84')
m.drawparallels(np.arange(-90.,-60.0, 10.), linewidth=0.1)
m.drawmeridians(np.arange(-180.,181.,45.), linewidth=0.1, latmax=90)
m.drawmapboundary(linewidth=2, color='k')
plt.savefig("test.png",dpi=600, transparent=True)
plt.show()
This results in:
I marked the cropped off part with red ellipses (top and left). It doesn't make a difference if I change the "linewidth" parameter.
Is there a workaround for this problem to make the boundary evenly in line width? Thanks for any help and suggestions in advance!
Upvotes: 2
Views: 601
Reputation: 1
I used circle.set_clip_on(False)
option, thank you! Now the continents and rivers are plotted on top of the circle boundary, although I tried changing the zorder of the plotting. How could I fix this please?
Here's my code :
from mpl_toolkits.basemap import Basemap;
import numpy as np;
import matplotlib.pyplot as plt;
fig, ax = plt.subplots(1, 1, figsize=(9,7));
m = Basemap(projection='npstere', boundinglat=70, lon_0=0, resolution='l', round=True);
m.fillcontinents(color='silver');
m.drawcoastlines(color='w');
m.drawparallels(np.arange(70.,81.,10.),labels=[False,False,False,False], fontsize=ft);
m.drawmeridians(np.arange(0.,360.,90.),labels=[True,True,True,True], fontsize=ft);
circle = m.drawmapboundary(linewidth=3, color='k');
circle.set_clip_on(False);
plt.show()
And here is what it shows :
Upvotes: 0
Reputation: 339430
The circle that defines the map boundary is clipped by the actual axes in use. You may use the clip_on
option to let it not be clipped.
circle = m.drawmapboundary(linewidth=2, color='k')
circle.set_clip_on(False)
The example code then look like this
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
m = Basemap(projection='spstere', boundinglat=-60, lon_0=180,
lat_ts=-71, round=True, ellps='WGS84')
m.drawparallels(np.arange(-90.,-60.0, 10.), linewidth=0.1)
m.drawmeridians(np.arange(-180.,181.,45.), linewidth=0.1, latmax=90)
circle = m.drawmapboundary(linewidth=2, color='k')
circle.set_clip_on(False)
plt.savefig("test.png",dpi=600, transparent=True)
plt.show()
Upvotes: 2