Following up on my previous question, I’m having some trouble repositioning my legend to where I want it to be. In the aforementioned post, my legend was attached to the second subplot, but I want to put it below the two plots. Such as in the left plot here.
Here’s my existing code:
a_combined_path = 'c:\mypath'
fig, (ax1, ax2) = plt.subplots(1,2, layout='constrained')
fig.set_size_inches(10,10)
a_2020.plot(ax=ax1, column='Party Vote Share', cmap='Greens', edgecolor='black', linewidth = 0.5, norm=norm)
a_dublin.plot(ax=ax2, column='Party Vote Share', cmap='Greens', edgecolor='black', linewidth = 0.5, norm=norm)
ax1.set_axis_off()
ax2.set_axis_off()
ax1.set_title('Republic of Ireland', size = 16)
ax2.set_title('Dublin', size = 16)
fig.suptitle('Aontú vote share in the 2020 electionsnby constituency (Pct of total vote)', size = 16)
plt.savefig(a_combined_path, dpi=600)
I’ve tried putting legend=True, legend_kwds={loc: 'lower right'}
in a_2020.plot(...)
, but apparently colorbar
doesn’t take loc
as an argument. I’ve tried using fig.colorbar
, but I can’t seem to get imshow
to work with my dataframe. Also, it doesn’t even need to strictly be a colorbar, I’d be perfectly happy with something like the legend here. I’m just trying to get it to be positioned in the lower center of my figure, something I mistakenly thought would be a straightforward exercise.
Any help would be much appreciated, as I’ve spent my day so far going in circles on this.