plt.axis('tight') applies only on the last axis. How do I apply it to all three axises on the figure?
The data source looks like this.
And the code is:
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
patterns = [ "\\" , "/" , "-","+" ,"x", "|",":", "<", "O" ]
file_locn4 = ''r'data.csv'''
df = pd.read_csv(file_locn4)
grouped = df.groupby('A')
fig, axs = plt.subplots(1,3,figsize=(5,3))#,sharey=True)
for (name, df), ax in zip(grouped, axs.flat):
df.plot(x='dataset',kind='bar', ax=ax,legend=False)
handles, labels = ax.get_legend_handles_labels()
for ax in fig.axes:
bars = ax.patches
hatches = ''.join(h*len(df) for h in patterns)
for bar, hatch in zip(bars, hatches):
bar.set_hatch(2*hatch)
ax.legend(loc=1, bbox_to_anchor=(.70, 1.16), ncol=4) # ,fontsize=14)
for ax in fig.axes:
plt.setp(ax.get_xticklabels(), rotation=360)
plt.axis('tight')
plt.savefig('fig.pdf')
plt.show()
I want all three subplots to look like the last one(subplot D)