如何使用 pysal 或 geopandas 并排绘制两张地图?

Oal*_*gro 2 python maps geopandas pysal

我想并排绘制两个 tematic 地图以进行比较。我正在使用 geopandas 绘制地图和 pysal 从空间分析生成地图。

jor*_*ris 6

您可以使用 matplotlib 创建子图结构,然后将带有 geopandas/pysal 的图添加到特定的子图:

import matplotlib.pyplot as plt

fig, axes = plt.subplots(ncols=2)
# add geopandas plot to left subplot
geodataframe.plot(..., ax=axes[0])
# add pysal plot to right subplot using `axes[1]`
Run Code Online (Sandbox Code Playgroud)


小智 5

为了并排获得两个 geopandas 地图,您可以编写:

fig, (ax1,ax2) = plt.subplots(nrows=1, ncols=2, figsize=(20, 16))
ax1 = geodataframe.plot(ax=ax1, column='obs', legend=True)
ax2 = geodataframe.plot(ax=ax2, column='pred', legend=True)
Run Code Online (Sandbox Code Playgroud)