如何使 geopandas 地图共享 x 和 y 轴?

时间:2021-03-17 07:36:53

标签: python matplotlib subplot geopandas

嘿,

我尝试将 geopandas 地图包含到具有多个子图的图形中。 Here is a first draft. 不幸的是,我无法强制左下方的地图与其周围的直方图共享其 y 和 x 轴。 到目前为止,这是我的代码:

plt.figure(figsize=(14,14))
grid = (7,7)
map_ax = plt.subplot2grid(grid, (3,0), rowspan=4, colspan=4)
lat_ax = plt.subplot2grid(grid, (3,4), rowspan=4, colspan=1, sharey=map_ax)
lon_ax = plt.subplot2grid(grid, (2,0), rowspan=1, colspan=4, sharex=map_ax)
scatter_ax = plt.subplot2grid(grid,(1, 4), rowspan=2, colspan=2)
elev_ax = plt.subplot2grid(grid, (1,6), rowspan=2, colspan=1, sharey=scatter_ax)
size_ax = plt.subplot2grid(grid, (0,4), rowspan=1, colspan=2, sharex=scatter_ax)

points.plot(ax=map_ax)
lat_ax.hist(lat, orientation='horizontal')
lat_ax.set_yticks([])
lon_ax.hist(lon)
lon_ax.set_xticks([])
elev_ax.hist(elev, orientation='horizontal')
size_ax.hist(size)
scatter_ax.plot(size, elev, '.')

感谢您的帮助和任何前进的想法,

干杯, 斯文

更新

我认为如果我在 aspect=None 中设置 points.plot(ax=map_ax) 它应该可以解决问题。不幸的是,我似乎不允许设置 aspect=None:

TypeError: float() argument must be a string or a number, not 'NoneType'

有什么想法吗?也许我在这里找不到解决方案,有人可以为我指明正确的方向...谢谢。

0 个答案:

没有答案
相关问题