简体   繁体   中英

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:-

@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)? (Technically they could of course be EuroPP coordinates, just really close to the origin)

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)

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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