Я создаю мультиплот с Geo Pandas GeoDataFrame.plot()
для каждого месяца. Как я могу использовать общую легенду, а также оси x и y для всех подсюжетов и управлять размером фигуры?.
Я знаю, что есть sharex=True
и sharey=True
, но я не знаю, где его разместить.
plt.figure(sharex=True, sharey=True)
возврат TypeError: __init__() got an unexpected keyword argument 'sharex'
world.plot(column='pop_est', ax=ax, legend=True, sharex=True, sharey=True)
возврат AttributeError: 'PatchCollection' object has no property 'sharex'
ax = plt.subplot(4, 3, index + 1, sharex=True, sharey=True)
возврат TypeError: cannot create weak reference to 'bool' object
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
months = pd.DataFrame(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
columns = ['months'])
plt.figure()
for index, i in months.iterrows():
ax = plt.subplot(4, 3, index + 1) # nrows, ncols, axes position
world.plot(column='pop_est', ax=ax, legend=True)
ax.set_title(index)
ax.set_aspect('equal', adjustable='datalim')
plt.suptitle('This is the figure title', fontsize=12, y=1.05)
plt.tight_layout()
plt.show()