olbinado11
olbinado11

Reputation: 161

Mapping with Layers in GeoPandas and Matplotlib: Issue is I cannot set the desired fig size

Idea is to plot in layers having a base map(r5_base) and then overlay by gpd a 'regionbybranch'.

As can be seen from images below, two figures were created but I am expecting only one. The desired map was plot correctly with the second figure but it did not follow the desired 'figsize'

# Isolate Region on map 
r5_base = bars[bars.Reg_Name=='REGION V (BICOL REGION)']
# Isolate region from OP data
region=mpabars_gdf[mpabars_gdf.RegionName=='Bicol Region']

# Plot area.
regionbybranch = region.dissolve(by='BranchName', aggfunc='sum',as_index=False)

fig, ax = plt.subplots(1,1,sharex=True, sharey= True, figsize=(30,30))
base = r5_base.plot(color='gray')

regionbybranch.plot(ax=base, linewidth=0.5, edgecolor='black', legend= False, column='Penetration',cmap='viridis')

# plt.title('Market Penetration on Bicol Region');
# fig.savefig(“map_export.png”, dpi=300)

enter image description here

Upvotes: 0

Views: 204

Answers (1)

baccandr
baccandr

Reputation: 1130

I think you have to set the proper axes name when you call the plot function. Something like this should work:

fig, ax = plt.subplots(1,1,sharex=True, sharey= True, figsize=(30,30))
base = r5_base.plot(ax=ax,color='gray')

regionbybranch.plot(ax=ax, linewidth=0.5, edgecolor='black', 
            legend= False, column='Penetration',cmap='viridis')

Upvotes: 1

Related Questions