Matplotlib Mollweide/Hammer投影:仅关注区域 [英] Matplotlib Mollweide/Hammer projection: region of interest only

查看:234
本文介绍了Matplotlib Mollweide/Hammer投影:仅关注区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以仅基于底图(matplotlib)中基于Mollweide/Hammer投影的图来显示感兴趣区域.

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).

我正尝试将绘图范围大致设置为太平洋板块,如下面的链接中所示.但是,set_xlim和set_ylim函数似乎没有任何作用.预先感谢您的指导.

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

推荐答案

根据文档,HammerMollweide投影都不允许这样做,因为它们会打印出整个世界地图.这是一些使用Polyconic投影的代码,但受直线限制.这里的技巧是在创建时定义拐角经度和纬度.

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()

结果:

请注意,这实际上显示的区域少于您提供的图片中的区域.

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

这篇关于Matplotlib Mollweide/Hammer投影:仅关注区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆