将条形图添加到 cartopy 地图

发布于 2025-01-10 12:59:33 字数 1233 浏览 3 评论 0原文

有没有办法在 cartopy 地图上添加条形图?

这是我目前的代码:

latN = 42.0
latS = 32.0
lonW = -125.0
lonE = -115.0
cLat = (latN + latS)/2
cLon = (lonW + lonE)/2

data_6 = all_data.loc[(all_data['temp'] >= 95)]
lats_6, lons_6 = data_6['event_lat'], data_6['event_lon']

data_6_a = data_6['Date'].groupby([data_6.Date.dt.month]).agg('count')
data_6_a = data_6_a.to_frame()
data_6_a.columns = ['Occurrences']
data_6_a = data_6_a.reset_index()
data_6_a.columns = ['Month', 'Occurrences']

proj = ccrs.LambertConformal(central_longitude=cLon, central_latitude=cLat)
res = '10m'
fig_1 = plt.figure(figsize=(20,20))
ax_1 = plt.subplot(1,1,1,projection=proj)
ax_1.set_extent([lonW,lonE,latS,latN])
ax_1.add_feature(cfeature.LAND.with_scale(res))
ax_1.add_feature(cfeature.OCEAN.with_scale(res))
ax_1.add_feature(cfeature.COASTLINE.with_scale(res))
ax_1.add_feature(cfeature.LAKES.with_scale(res), alpha = 0.5)
ax_1.add_feature(cfeature.STATES.with_scale(res));
ax_1.set_title('Sites in California with Temperature Values Above 95 degrees F, 2020', fontsize=20)
ax_1.scatter(lons_6,lats_6,s=100,c='r',edgecolor='black',alpha=0.75,transform=ccrs.PlateCarree())

我想添加一个条形图,显示按月向我的 cartopy 地图(位于加利福尼亚州)的地图水域部分的事件数量。有办法做到这一点吗?

Is there anyway to add a bar chart to a cartopy map?

Here is my code currently:

latN = 42.0
latS = 32.0
lonW = -125.0
lonE = -115.0
cLat = (latN + latS)/2
cLon = (lonW + lonE)/2

data_6 = all_data.loc[(all_data['temp'] >= 95)]
lats_6, lons_6 = data_6['event_lat'], data_6['event_lon']

data_6_a = data_6['Date'].groupby([data_6.Date.dt.month]).agg('count')
data_6_a = data_6_a.to_frame()
data_6_a.columns = ['Occurrences']
data_6_a = data_6_a.reset_index()
data_6_a.columns = ['Month', 'Occurrences']

proj = ccrs.LambertConformal(central_longitude=cLon, central_latitude=cLat)
res = '10m'
fig_1 = plt.figure(figsize=(20,20))
ax_1 = plt.subplot(1,1,1,projection=proj)
ax_1.set_extent([lonW,lonE,latS,latN])
ax_1.add_feature(cfeature.LAND.with_scale(res))
ax_1.add_feature(cfeature.OCEAN.with_scale(res))
ax_1.add_feature(cfeature.COASTLINE.with_scale(res))
ax_1.add_feature(cfeature.LAKES.with_scale(res), alpha = 0.5)
ax_1.add_feature(cfeature.STATES.with_scale(res));
ax_1.set_title('Sites in California with Temperature Values Above 95 degrees F, 2020', fontsize=20)
ax_1.scatter(lons_6,lats_6,s=100,c='r',edgecolor='black',alpha=0.75,transform=ccrs.PlateCarree())

I want to add a bar chart that shows the number of events by month to my cartopy map - which is of California - in the area of water portion of the map. Is there a way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文