简体   繁体   English

为什么散点图不能在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()

Why there is only a map, and the scatter plot cannot be on the map?为什么只有地图,而散点图不能在地图上?

According to the source code https://scitools.org.uk/cartopy/docs/v0.15/_modules/cartopy/crs.html#EuroPP The plotting limits are set in the lines of code:-根据源代码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)

The values are in projection coordinates with meters unit.这些值采用以米为单位的投影坐标。 The scatter points that fall outside these limits will not be plotted.超出这些限制的散点将不会被绘制。

The transform you specify for the scatter should be the projection of the data, not the map.您为散点指定的变换应该是数据的投影,而不是地图。 It looks as if they are lat/lon values (epsg:4326)?看起来好像它们是纬度/经度值(epsg:4326)? (Technically they could of course be EuroPP coordinates, just really close to the origin) (从技术上讲,它们当然可以是 EuroPP 坐标,只是非常接近原点)

Where do you expect those points to be more or less?您希望这些点或多或少在哪里?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM