![](/img/trans.png)
[英]Python: How to plot scatter plot at specific point on map in cartopy?
[英]why the scatter plot can not be on the map created by cartopy
plt.figure(figsize = (10,10),dpi =150)
ax = plt.axes(projection=ccrs.EuroPP())
ax.coastlines(resolution='50m')
ax.set_extent([-16., 5., 49., 61.])
plt.scatter([10.,15.],[52.5,55.],marker='o',s = 100,
transform = ccrs.EuroPP(), color = "red")
ax.gridlines(draw_labels=True)
plt.show()
为什么只有地图,而散点图不能在地图上?
根据源代码https://scitools.org.uk/cartopy/docs/v0.15/_modules/cartopy/crs.html#EuroPP在代码行中设置plotting limits
:-
@property
def x_limits(self):
return (-1.4e6, 2e6)
@property
def y_limits(self):
return (4e6, 7.9e6)
这些值采用以米为单位的投影坐标。 超出这些限制的散点将不会被绘制。
您为散点指定的变换应该是数据的投影,而不是地图。 看起来好像它们是纬度/经度值(epsg:4326)? (从技术上讲,它们当然可以是 EuroPP 坐标,只是非常接近原点)
您希望这些点或多或少在哪里?
map_proj = ccrs.EuroPP()
data_proj = ccrs.PlateCarree()
fig, ax = plt.subplots(
figsize=(10,10), dpi=76,
subplot_kw=dict(projection=map_proj),
)
ax.scatter(
[10.,15.],[52.5,55.], marker='o', s=100,
color="r", transform=data_proj,
)
ax.coastlines(resolution='50m')
ax.set_extent([-5., 20., 49., 61.], crs=data_proj)
ax.gridlines(draw_labels=True)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.