I realized that matplotlib tight_layout() cannot be applied to charts generated by pandas .
This is the code I'm running:
0 1 2 3 4
A 0.039895 0.960105 NaN NaN NaN
D 0.030418 0.969582 NaN NaN NaN
E 0.037345 0.962655 NaN NaN NaN
F 0.061522 0.938478 NaN NaN NaN
G 0.047163 0.952837 NaN NaN NaN
H 0.026423 0.000000 0.000000 0.973577 NaN
df.T.plot(kind='bar', subplots=True, width=0.7, legend=False,
layout=(2,4), sharex=True, sharey=True)
plt.tight_layout()
I get the following error:
AttributeError: 'NoneType' object has no attribute 'is_bbox'
I also believe this is due to a similar issue posted on github:
DataFrame.hist () does not get along with matplotlib.pyplot.tight_layout () # 9351
Therefore, I am looking for a workaround based on subplots_adjust(*args, **kwargs). Most importantly, I tried to configure the parameter hspace. However, these keyword arguments are not accepted when calling the plot pandas function .
Any suggestions?
source
share