I have a set of 7 *xls files (until now) in a folder, those are statistics for each month, with Pandas I read all of them, then I select the column called "Gap" and made some filtering to keep working. I tried to plot histograms of each "Gap" in one subplot (a Gap per month inside a subplot). The code I did is:
pato = r'D:\Inves\Pdoc\Cata_2021'
#os.chdir(pato)
file_list = glob.glob(pato + r"\*.xls")
print('file_list {}'.format(file_list))
print(file_list)
fig, axs = plt.subplots(4,3, figsize=(15, 6), sharex=True, sharey=True)
a = 4
b = 3
# this for loop read all files with Pandas and
for proce in file_list:
df_cat = pd.read_excel(proce)
#print(df_cat.head())
df_cat_sha = df_cat[(df_cat.Prof.between(0, 75))]
print(df_cat_sha)
m = 0
# Here I tried to create the subplot's and populate them
for i in range(a):
for j in range(b):
df_cat_sha.Gap.hist(bins=18, ax=axs[i, j],
color='green', alpha=0.75)
m +=1
plt.show()
I got the following plot (with help of Plotting two histograms from a pandas DataFrame in one subplot using matplotlib)
However, you can see that in each subplot there are more than one histogram, which is that I do not wanted.
The desired output is like this example
Do you have any tip to plot just one histogram "Gap" from my DataFrame in one subplot?, here I attach the files in xls format too (https://drive.google.com/drive/folders/1MbuTMQpuc79nRYFGL-UAdmvo9r2AzhxA?usp=sharing)
Thanks in advance
Tonino