def bringPlotOverSameX(data, nsample=None):
x0 = [x[<NUM_LIT:0>] for x, _ in data if len(x)]<EOL>x1 = [x[-<NUM_LIT:1>] for x, _ in data if len(x)]<EOL>xmin = min(np.min(x0), np.min(x1))<EOL>xmax = max(np.max(x0), np.max(x1))<EOL>if nsample is None:<EOL><INDENT>pn_per_dist = np.mean([len(x) / (abs(x[<NUM_LIT:0>] - x[-<NUM_LIT:1>]))<EOL>for x, _ in data if len(x)])<EOL>nsample = round(pn_per_dist * abs(xmax - xmin))<EOL><DEDENT>xArr = np.linspace(xmin, xmax, nsample)<EOL>if x0[<NUM_LIT:0>] > x1[<NUM_LIT:0>]:<EOL><INDENT>interpol = [np.interp(xArr, x[::-<NUM_LIT:1>], y[::-<NUM_LIT:1>],<EOL>left=np.nan, right=np.nan) for x, y in data if len(x)]<EOL><DEDENT>else:<EOL><INDENT>interpol = [np.interp(xArr, x, y,<EOL>left=np.nan, right=np.nan) for x, y in data if len(x)]<EOL><DEDENT>return xArr, interpol<EOL>
bring all plots (x,y)
to same x value base