-
Notifications
You must be signed in to change notification settings - Fork 24
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
clip时,当地图边界范围大于数据范围时会导致裁切后大范围留白,求问怎么解决 #97
Comments
收到,我测试一下 |
@huddao 你试一下这个样例: import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cnmaps import get_adm_maps, clip_contours_by_map, draw_maps, MapPolygon
from cnmaps.sample import load_temp
from shapely.geometry import Polygon
fig = plt.figure(figsize=(6, 5), dpi=300)
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], projection=ccrs.PlateCarree())
lons, lats, data = load_temp()
cs = ax.contourf(lons, lats, data)
boundary = MapPolygon(
[Polygon([[70, 55], [140, 55], [140, 40], [70, 40], [70, 55]])]
) & get_adm_maps(country="中华人民共和国", only_polygon=True, record="first")
draw_maps(get_adm_maps(country="中华人民共和国"), ax)
clip_contours_by_map(cs, boundary, ax)
ax.set_extent([70, 140, 40, 55], crs=ccrs.PlateCarree())
fig.savefig("./test.png", bbox_inches="tight") |
感谢,完美解决 |
记录:可以通过ax的get_extent方法获取到边界,再通过 |
Open
Open
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
裁切前:
裁切后会导致大范围留白:
找了很久都没解决,希望能帮忙看看是哪里的问题。
The text was updated successfully, but these errors were encountered: