import matplotlib.pyplot as plt import numpy as np import os import nix_helpers as nh from IPython import embed identifier = ['2013eigen13', '2015eigen16', '2015eigen17', '2015eigen19', '2020eigen22', '2020eigen32'] for ID in identifier: res_df = np.load('res_df_%s.npy' %ID) mres = [] mdf = [] currf = None idxlist = [] for i, d in enumerate(res_df): if currf is None or currf == d[0]: currf = d[0] idxlist.append(i) else: # currf != f meanres = [] # lists to make mean of meandf = [] for x in idxlist: meanres.append(res_df[x][1]) meandf.append(res_df[x][0]) meanedres = np.mean(meanres) meaneddf = np.mean(meandf) mres.append(meanedres) mdf.append(meaneddf) currf = d[0] # set back for next loop idxlist = [i] meanres = [] # lists to make mean of meandf = [] for y in idxlist: meanres.append(res_df[y][1]) meandf.append(res_df[y][0]) meanedres = np.mean(meanres) meaneddf = np.mean(meandf) mres.append(meanedres) mdf.append(meaneddf) plt.plot(mdf, mres, 'o') plt.xlabel('deltaf [Hz]') plt.ylabel('JAR_respones [Hz]') plt.axhline(0, color='grey', lw =1) plt.axvline(0, color='grey', lw = 1) plt.title('JAR_response_to_deltaf_%s' %ID) plt.show()