def plot_profile_histogram(x, y, n_bins=<NUM_LIT:100>, title=None, x_label=None, y_label=None, log_y=False, filename=None):
if len(x) != len(y):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>n, bin_edges = np.histogram(x, bins=n_bins)  <EOL>sy = np.histogram(x, bins=n_bins, weights=y)[<NUM_LIT:0>]  <EOL>sy2 = np.histogram(x, bins=n_bins, weights=y * y)[<NUM_LIT:0>]  <EOL>bin_centers = (bin_edges[<NUM_LIT:1>:] + bin_edges[:-<NUM_LIT:1>]) / <NUM_LIT:2>  <EOL>mean = sy / n  <EOL>std = np.sqrt((sy2 / n - mean * mean))  <EOL>std_mean = std / np.sqrt((n - <NUM_LIT:1>))<EOL>mean[np.isnan(mean)] = <NUM_LIT:0.0><EOL>std_mean[np.isnan(std_mean)] = <NUM_LIT:0.0><EOL>fig = Figure()<EOL>FigureCanvas(fig)<EOL>ax = fig.add_subplot(<NUM_LIT>)<EOL>ax.errorbar(bin_centers, mean, yerr=std_mean, fmt='<STR_LIT:o>')<EOL>ax.set_title(title)<EOL>if x_label is not None:<EOL><INDENT>ax.set_xlabel(x_label)<EOL><DEDENT>if y_label is not None:<EOL><INDENT>ax.set_ylabel(y_label)<EOL><DEDENT>if log_y:<EOL><INDENT>ax.yscale('<STR_LIT>')<EOL><DEDENT>ax.grid(True)<EOL>if not filename:<EOL><INDENT>fig.show()<EOL><DEDENT>elif isinstance(filename, PdfPages):<EOL><INDENT>filename.savefig(fig)<EOL><DEDENT>else:<EOL><INDENT>fig.savefig(filename)<EOL><DEDENT>
Takes 2D point data (x,y) and creates a profile histogram similar to the TProfile in ROOT. It calculates
    the y mean for every bin at the bin center and gives the y mean error as error bars.

    Parameters
    ----------
    x : array like
        data x positions
    y : array like
        data y positions
    n_bins : int
        the number of bins used to create the histogram