I'm trying to set figure labels for my conditioned hexagonal binning plot, but when I run this code I get the Attribute Error: 'Figure'object has no attribute 'supxlabel'
. Any help with this problem would be appreciated.
zip_codes = [98188, 98105, 98108, 98126]
def hexbin_zips(ax, zipcode):
kc_tax_zip = kc_tax_stripped.loc[kc_tax_stripped['ZipCode'] == zipcode]
out = ax.hexbin(kc_tax_zip['SqFtTotLiving'], kc_tax_zip['TaxAssessedValue'], gridsize=30)
return out
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(12, 10), sharex='col', sharey='row')
axes = [ax1, ax2, ax3, ax4]
for n in range(4):
hexbin_zips(axes[n], zip_codes[n])
axes[n].set_title(str(zip_codes[n]))
fig.supxlabel('Total Living Space in Square Feet', fontsize=16.)
fig.supylabel('Tax-Assessed Value', fontsize=16.)
add_axes plot inside plot matplotlib To create a figure object, use the figure() method. To define data points x and y. To plot a graph, use the plot() method of pyplot module. To add a plot inside an already generated plot, use the add_axes() method.
I got into the same problem when using the answer given here. It turns out that you need 2 things:
pip install --upgrade matplotlib
).If you have Python under 3.7, the install of version 3.4 of matplotlib
won't work (at least it didn't in my case).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With