【问题标题】:Why does a frame around an image leave a corner incomplete?为什么图像周围的框架会留下不完整的角落?
【发布时间】:2022-01-19 16:17:43
【问题描述】:

在下面的最小示例中,我尝试在图像周围设置边框。但是左下角仍然是空白的。需要做什么来填满它?

import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs

plt.figure(figsize=(152, 90), dpi=10)
ax = plt.axes(projection=ccrs.PlateCarree(145))
land = cartopy.feature.NaturalEarthFeature('physical', 'land', scale='50m')
ocean = cartopy.feature.NaturalEarthFeature('physical', 'ocean', scale='50m')
ax.add_feature(land, facecolor='gray')
ax.add_feature(ocean, facecolor='black')
ax.patch.set_edgecolor('red')
ax.patch.set_linewidth('1000')  # exaggerated width for example
plt.savefig('islands.png', pad_inches=10)
plt.show()

输出:

【问题讨论】:

    标签: python matplotlib cartopy


    【解决方案1】:

    补丁的默认capstyle(即PathPatch)为'butt',设置为'projecting'

    ax.patch.set_capstyle('projecting')
    

    【讨论】:

    • 还不能投票,所以...谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-15
    • 2014-10-18
    • 2014-01-25
    • 1970-01-01
    • 2011-10-05
    • 2015-12-06
    相关资源
    最近更新 更多