Matplotlib Mollweide/Hammer projection: region of interest only

て烟熏妆下的殇ゞ 提交于 2020-01-06 01:16:53

问题


I was wondering if there's a way to only show the region of interest from a plot based on Mollweide/Hammer projection in basemap (matplotlib).

I am trying to set the plot-bounds roughly to the Pacific plate, as in the link below. However, the set_xlim and set_ylim functions do not seem to have any effect. Thanks in advance for any guidance.

http://geology.gsapubs.org/content/29/8/695/F1.large.jpg


回答1:


From the documentation, both Hammer and Mollweide projections don't allow this as they print out entire world maps. Here's some code using Polyconic projection, but it is bounded by straight lines. The trick here is to define the corner longitude and latitudes on creation.

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np

my_map = Basemap(projection='poly', lat_0=0, lon_0=-160,
    resolution = 'h', area_thresh = 0.1,
    llcrnrlon=140, llcrnrlat=-60,
    urcrnrlon=-100, urcrnrlat=60)

plt.figure(figsize=(16,12))

my_map.drawcoastlines()
my_map.drawcountries()
my_map.fillcontinents(color='coral', lake_color='aqua')
my_map.drawmapboundary(fill_color='aqua')

my_map.drawmeridians(np.arange(0, 360, 20))
my_map.drawparallels(np.arange(-90, 90, 10))

plt.show()

Result:

Note that this effectively shows less area than the one in the picture you provided.



来源:https://stackoverflow.com/questions/31176169/matplotlib-mollweide-hammer-projection-region-of-interest-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!