Yai*_*aon 3 python-3.x cartopy
以下代码(从此处复制)在纽约市和新德里之间生成一条漂亮的测地线。仔细检查后,测地线看起来并不平滑。怎样才能让它看起来光滑呢?
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ny_lon, ny_lat = -75, 43
delhi_lon, delhi_lat = 77.23, 28.61
ax = plt.axes(projection=ccrs.PlateCarree())
ax.stock_img()
plt.plot([ny_lon, delhi_lon], [ny_lat, delhi_lat],
linewidth=2, marker='o', transform=ccrs.Geodetic())
plt.tight_layout()
plt.show()
Run Code Online (Sandbox Code Playgroud)
您需要沿绘制的测地线设置更精细的线段阈值。以下是执行此操作的相关代码行。
plateCr = ccrs.PlateCarree()
# print(plateCr._threshold) # original threshold=0.5
plateCr._threshold = plateCr._threshold/10. #set finer threshold
ax = plt.axes(projection=plateCr)
Run Code Online (Sandbox Code Playgroud)
更换线路:
ax = plt.axes(projection=ccrs.PlateCarree())
Run Code Online (Sandbox Code Playgroud)
与上面建议的代码。结果图应如下所示:
| 归档时间: |
|
| 查看次数: |
792 次 |
| 最近记录: |