I have two dataframes, one with daily PM2.5/PM10 ratios for 7 years with about 30 sites. The other dataframe has the mean, standard deviation, and n value for each site. Sites of both dataframes are in the same order. My goal is to make a histogram for each site (each figure in a separate window) and then paste text onto the figure from the other dataframe that includes the corresponding site's mean, std dev, and n. Here are two csv files with my data.
pmf = https://drive.google.com/file/d/1heF1W1x0qS_5SjjPg23j5alt2WiY3HsM/view?usp=sharing
stats_all = https://drive.google.com/file/d/16ik-OY83j0p21SCy8PwXWQnz2nYvc-HV/view?usp=sharing
Here's my code so far:
import pandas as pd
stats_all = pd.read_csv('*****/R2PMratio_meanstdn.csv')
pmf = pd.read_csv('*****/PM25PM10ratio_dailyavg_IVAN.csv')
stats_all = stats_all.set_index('stats')
pmf = pmf.set_index('Date')
pmf.index = pd.to_datetime(pmf.index)
##this code makes the histograms for each site
for i,col in enumerate(pmf.columns):
plt.figure(i)
sns.histplot(pmf[col], binwidth=0.05, color='green')
plt.xlim(0,1)
plt.xlabel('PM$_{2.5}$/PM$_{10}$', fontsize=15)
plt.ylabel('Frequency', fontsize=15)
plt.title(pmf.columns[i], fontsize=20)
#plt.savefig(pmf.columns[i] + '_pmratio.png', dpi=400)
I'm not sure how to add the mean, standard deviation, and n value to the figure so that it loops through and puts the correct mean, std dev, and n on the corresponding site figure. I assume I would add something like this to the loop:
plt.text(0.5, 0.85, "mean = " __?__, horizontalalignment='center',
verticalalignment='center',
transform=ax.transAxes)
plt.text(0.5, 0.8, "stdv = " __?__, horizontalalignment='center',
verticalalignment='center',
transform=ax.transAxes)
plt.text(0.5, 0.75, "n = " __?__, horizontalalignment='center',
verticalalignment='center',
transform=ax.transAxes)
but I don't know what I would put in place of the question marks. I haven't had much luck finding anything on Stack Overflow.