如何在同一图上很好地处理正常和摄影投影?

发布于 2025-02-01 01:03:41 字数 745 浏览 7 评论 0原文

我想产生这种数字,取自Sallee等人。 (2021)如果可能的话,直接从python出发:

“图目标”

有一个Cartopy投影CATTOPY.CRS.ROBINSON(Central_Longitude = 0,Globe = NONE)它的权利接近我在Cartopy投影上的价值的密度函数(超过纬度)。使用Robinson投影管理标签对我来说并不方便,而使用CATTOPY.CRS.PLATECARREE(Central_longitude = 0.0,Globe = NONE)我没有任何标记轴的问题。

这是最相关的主题(正常和Cartopy的组合我现在在堆栈上建立的同一图中的子图),但这并没有敲响任何铃铛,因为我的目标图有点复杂(罗宾逊投影上方的配色栏的大小,两个虚线以链接。子图,标记纵向和纬度)。

谢谢 !

I want to produce this kind of figure, taken from Sallee et al. (2021) directly from Python if it is possible :

Figure goal

There is a Cartopy projection cartopy.crs.Robinson(central_longitude=0, globe=None) in the main subplot and at the right of it something close to a density function (over the latitudes) of my value on the Cartopy projection. Managing the labels with Robinson projection is not convenient for me, whereas with cartopy.crs.PlateCarree(central_longitude=0.0, globe=None) I did not have any issues labelling axis.

This is the most related topics (combination of normal and cartopy subplots within the same figure) that I have founded on stack for now but that doesn't ring any bell since my goal plot is a bit more complicated (size of the colorbar above the Robinson projection, two dashed lines to link the subplots, labelling longitudes and latitudes).

Thank you !

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄人书 2025-02-08 01:03:41

您没有任何您没有设法创建的具体特定内容?您所要求的大部分都可以从Cartopy/Matplotlib获得。

Matplotlib的其他注释,例如插图变焦行,例如:
“ nofollow noreferrer”> htttps:/

但是,我个人会避免这种情况,并简单地对齐轴,以确保它们共享相同的纬度。对于试图解释数据的用户来说,这可能更直观。

一个随机数据的快速示例:

lats = np.linspace(90-6, -90+6, 15)
data = np.random.randn(15, 32)

proj = ccrs.Robinson(central_longitude=0, globe=None)

fig = plt.figure(figsize=(11, 5), dpi=86, facecolor="w")
spec = fig.add_gridspec(9, 5)

ax1 = fig.add_subplot(spec[1:, :4], projection=proj)
im = ax1.imshow(
    data, cmap="Blues", vmin=-3, vmax=3,
    extent=[-180, 180,90,-90], transform=ccrs.PlateCarree())

cax = fig.add_subplot(spec[0, 1:-2])
cb1 = fig.colorbar(im, cax=cax, orientation="horizontal")
cax.set_title("Something [-]")
cax.xaxis.set_ticks_position('top')

grd = ax1.gridlines(
    draw_labels=True, 
    xlocs=range(-180, 181, 90), 
    ylocs=range(-60, 61, 30), 
    color='k',
)
grd.top_labels = False

ax1.add_feature(cfeature.LAND, facecolor="#eeeeee", zorder=99)


ax2 = fig.add_subplot(spec[1:, -1])
ax2.plot(data.mean(axis=1), lats)
ax2.axvline(0, color="k", lw=1)
ax2.set_xlim(-0.5, 0.5)
ax2.set_yticks(range(-60, 61, 30))
ax2.yaxis.set_label_position("right")
ax2.yaxis.tick_right()
ax2.grid(axis="y")
ax2.set_ylabel("Latitude [deg]")

”在此处输入图像说明”

Is there anything specific that you didn't manage to create? Most of what you ask for is readily available from Cartopy/Matplotlib.

Additional annotation, like the inset zoom lines are possible with Matplotlib, see for example:
https://matplotlib.org/stable/gallery/subplots_axes_and_figures/zoom_inset_axes.html

But I personally would avoid that and simply align the axes to make sure they share the same latitude. That's probably more intuitive for users trying to interpret the data.

A quick example with some random data:

lats = np.linspace(90-6, -90+6, 15)
data = np.random.randn(15, 32)

proj = ccrs.Robinson(central_longitude=0, globe=None)

fig = plt.figure(figsize=(11, 5), dpi=86, facecolor="w")
spec = fig.add_gridspec(9, 5)

ax1 = fig.add_subplot(spec[1:, :4], projection=proj)
im = ax1.imshow(
    data, cmap="Blues", vmin=-3, vmax=3,
    extent=[-180, 180,90,-90], transform=ccrs.PlateCarree())

cax = fig.add_subplot(spec[0, 1:-2])
cb1 = fig.colorbar(im, cax=cax, orientation="horizontal")
cax.set_title("Something [-]")
cax.xaxis.set_ticks_position('top')

grd = ax1.gridlines(
    draw_labels=True, 
    xlocs=range(-180, 181, 90), 
    ylocs=range(-60, 61, 30), 
    color='k',
)
grd.top_labels = False

ax1.add_feature(cfeature.LAND, facecolor="#eeeeee", zorder=99)


ax2 = fig.add_subplot(spec[1:, -1])
ax2.plot(data.mean(axis=1), lats)
ax2.axvline(0, color="k", lw=1)
ax2.set_xlim(-0.5, 0.5)
ax2.set_yticks(range(-60, 61, 30))
ax2.yaxis.set_label_position("right")
ax2.yaxis.tick_right()
ax2.grid(axis="y")
ax2.set_ylabel("Latitude [deg]")

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文