def residual_plots(df, rep_stats=None, els=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']):
<EOL>As = []<EOL>Rs = []<EOL>analytes = [c for c in df.columns if ('<STR_LIT>' not in c) and ('<STR_LIT>' not in c)]<EOL>ratios = [c for c in df.columns if ('<STR_LIT>' in c)]<EOL>for e in els:<EOL><INDENT>if e == '<STR_LIT>':<EOL><INDENT>As.append('<STR_LIT>')<EOL><DEDENT>elif e == '<STR_LIT>':<EOL><INDENT>As.append('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>As.append([a for a in analytes if e in a][<NUM_LIT:0>])<EOL><DEDENT>Rs.append([r for r in ratios if e in r][<NUM_LIT:0>][:-<NUM_LIT:2>])<EOL><DEDENT>fig, axs = plt.subplots(len(els), <NUM_LIT:3>, figsize=(<NUM_LIT>, len(els) * <NUM_LIT:2>))<EOL>for i, (e, a) in enumerate(zip(Rs, As)):<EOL><INDENT>if a == '<STR_LIT>':<EOL><INDENT>m = <NUM_LIT><EOL>u = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>m = <NUM_LIT:1><EOL>u = '<STR_LIT>'<EOL><DEDENT>tax, lax, hax = axs[i]<EOL>x = df.loc[:, e + '<STR_LIT>'].values * m<EOL>yt = df.loc[:, e + '<STR_LIT>'].values * m<EOL>yl = df.loc[:, a].values * m<EOL>rt = yt - x<EOL>rl = yl - x<EOL>tax.scatter(x, rt, c=element_colour(a), s=<NUM_LIT:15>, lw=<NUM_LIT:0.5>, edgecolor='<STR_LIT:k>', alpha=<NUM_LIT:0.5>)<EOL>lax.scatter(x, rl, c=element_colour(a), s=<NUM_LIT:15>, lw=<NUM_LIT:0.5>, edgecolor='<STR_LIT:k>', alpha=<NUM_LIT:0.5>)<EOL>rt = rt[~np.isnan(rt)]<EOL>rl = rl[~np.isnan(rl)]<EOL>lims = np.percentile(np.hstack([rt, rl]), [<NUM_LIT>, <NUM_LIT:1>])<EOL>lims += lims.ptp() * np.array((-<NUM_LIT>, <NUM_LIT>))<EOL>bins = np.linspace(*lims, <NUM_LIT:100>)<EOL>kdt = stats.gaussian_kde(rt, <NUM_LIT>)<EOL>kdl = stats.gaussian_kde(rl, <NUM_LIT>)<EOL>hax.fill_betweenx(bins, kdl(bins), facecolor=element_colour(a), alpha=<NUM_LIT>, edgecolor='<STR_LIT:k>', lw=<NUM_LIT:0.5>, label='<STR_LIT>')<EOL>hax.fill_betweenx(bins, kdt(bins), facecolor=element_colour(a), alpha=<NUM_LIT>, edgecolor='<STR_LIT:k>', lw=<NUM_LIT:0.5>, label='<STR_LIT>')<EOL>hax.set_xlim([<NUM_LIT:0>, hax.get_xlim()[-<NUM_LIT:1>]])<EOL>tax.set_ylabel(e + '<STR_LIT>'+ u + '<STR_LIT:)>')<EOL>tax.text(<NUM_LIT>,<NUM_LIT>,fmt_RSS(rt), fontsize=<NUM_LIT:8>,<EOL>ha='<STR_LIT:left>', va='<STR_LIT>', transform=tax.transAxes)<EOL>lax.text(<NUM_LIT>,<NUM_LIT>,fmt_RSS(rl), fontsize=<NUM_LIT:8>,<EOL>ha='<STR_LIT:left>', va='<STR_LIT>', transform=lax.transAxes)<EOL>xlim = np.percentile(x[~np.isnan(x)], [<NUM_LIT:0>, <NUM_LIT>])<EOL>for ax in [tax, lax]:<EOL><INDENT>ax.set_xlim(xlim)<EOL><DEDENT>for ax in axs[i]:<EOL><INDENT>ax.set_ylim(lims)<EOL>ax.axhline(<NUM_LIT:0>, c='<STR_LIT:k>', ls='<STR_LIT>', alpha=<NUM_LIT>)<EOL>if rep_stats is not None:<EOL><INDENT>ax.axhspan(-rep_stats[e][<NUM_LIT:0>] * <NUM_LIT:2>, rep_stats[e][<NUM_LIT:0>] * <NUM_LIT:2>, color=(<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT>), zorder=-<NUM_LIT:1>)<EOL><DEDENT>if not ax.is_first_col():<EOL><INDENT>ax.set_yticklabels([])<EOL><DEDENT>if ax.is_last_row():<EOL><INDENT>hax.set_xlabel('<STR_LIT>')<EOL>tax.set_xlabel('<STR_LIT>')<EOL>lax.set_xlabel('<STR_LIT>')<EOL><DEDENT>if ax.is_first_row():<EOL><INDENT>tax.set_title('<STR_LIT>', loc='<STR_LIT:left>')<EOL>lax.set_title('<STR_LIT>', loc='<STR_LIT:left>')<EOL><DEDENT><DEDENT><DEDENT>fig.tight_layout()<EOL>return fig, axs<EOL>
Function for plotting Test User and LAtools data comparison.

Parameters
----------
df : pandas.DataFrame
    A dataframe containing reference ('X/Ca_r'), test user 
    ('X/Ca_t') and LAtools ('X123') data.
rep_stats : dict
    Reproducibility stats of the reference data produced by
    `pairwise_reproducibility`
els : list
    list of elements (names only) to plot.