def bringPlotOverSameX(data, nsample=None):
    """
    bring all plots (x,y)
    to same x value base
    """
    x0 = [x[0] for x, _ in data if len(x)]
    x1 = [x[-1] for x, _ in data if len(x)]

    xmin = min(np.min(x0), np.min(x1))
    xmax = max(np.max(x0), np.max(x1))

    if nsample is None:
        # calc from mean point density:
        pn_per_dist = np.mean([len(x) / (abs(x[0] - x[-1]))
                               for x, _ in data if len(x)])
        #...and max distance:
        nsample = round(pn_per_dist * abs(xmax - xmin))

    xArr = np.linspace(xmin, xmax, nsample)

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