Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot two maps side by side using pysal or geopandas?

I want to plot two tematic maps side by side to compare then. I am using geopandas to plot the maps and pysal to generate the maps from spatial analysis.

like image 718
Oalvinegro Avatar asked Sep 05 '25 03:09

Oalvinegro


2 Answers

You can create the subplots structure with matplotlib, and then add the plots with geopandas/pysal to the specific subplot:

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]`
like image 170
joris Avatar answered Sep 07 '25 19:09

joris


In order to get two geopandas maps side by side, you can write:

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)
like image 43
Panhypersebsatos Avatar answered Sep 07 '25 19:09

Panhypersebsatos