def dotplot(df, column='<STR_LIT>', title='<STR_LIT>', cutoff=<NUM_LIT>, top_term=<NUM_LIT:10>, <EOL>sizes=None, norm=None, legend=True, figsize=(<NUM_LIT:6>, <NUM_LIT>), <EOL>cmap='<STR_LIT>', ofname=None, **kwargs):
colname = column    <EOL>if colname in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>can_be_coerced = df[colname].map(isfloat)<EOL>if np.sum(~can_be_coerced) > <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>'%colname)<EOL><DEDENT>else:<EOL><INDENT>df.loc[:, colname] = df[colname].map(float)<EOL><DEDENT>df = df[df[colname] <= cutoff]<EOL>if len(df) < <NUM_LIT:1>: <EOL><INDENT>msg = "<STR_LIT>"%cutoff<EOL>return msg<EOL><DEDENT>df = df.assign(logAP=lambda x: - x[colname].apply(np.log10))<EOL>colname='<STR_LIT>'<EOL><DEDENT>df = df.sort_values(by=colname).iloc[-top_term:,:]<EOL>temp = df['<STR_LIT>'].str.split("<STR_LIT:/>", expand=True).astype(int)<EOL>df = df.assign(Hits=temp.iloc[:,<NUM_LIT:0>], Background=temp.iloc[:,<NUM_LIT:1>])<EOL>df = df.assign(Hits_ratio=lambda x:x.Hits / x.Background)<EOL>x = df.loc[:, colname].values<EOL>combined_score = df['<STR_LIT>'].round().astype('<STR_LIT:int>')<EOL>y = [i for i in range(<NUM_LIT:0>,len(df))]<EOL>ylabels = df['<STR_LIT>'].values<EOL>levels = numbers = np.sort(df.Hits.unique())<EOL>if norm is None:<EOL><INDENT>norm = Normalize()<EOL><DEDENT>elif isinstance(norm, tuple):<EOL><INDENT>norm = Normalize(*norm)<EOL><DEDENT>elif not isinstance(norm, Normalize):<EOL><INDENT>err = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>raise ValueError(err)<EOL><DEDENT>min_width, max_width = np.r_[<NUM_LIT:20>, <NUM_LIT:100>] * plt.rcParams["<STR_LIT>"]<EOL>norm.clip = True<EOL>if not norm.scaled():<EOL><INDENT>norm(np.asarray(numbers))<EOL><DEDENT>size_limits = norm.vmin, norm.vmax<EOL>scl = norm(numbers)<EOL>widths = np.asarray(min_width + scl * (max_width - min_width))<EOL>if scl.mask.any():<EOL><INDENT>widths[scl.mask] = <NUM_LIT:0><EOL><DEDENT>sizes = dict(zip(levels, widths))<EOL>df['<STR_LIT>'] = df.Hits.map(sizes)<EOL>area = df['<STR_LIT>'].values<EOL>if hasattr(sys, '<STR_LIT>') and (ofname is None):<EOL><INDENT>fig, ax = plt.subplots(figsize=figsize)<EOL><DEDENT>else:<EOL><INDENT>fig = Figure(figsize=figsize)<EOL>canvas = FigureCanvas(fig)<EOL>ax = fig.add_subplot(<NUM_LIT>)<EOL><DEDENT>vmin = np.percentile(combined_score.min(), <NUM_LIT:2>)<EOL>vmax =  np.percentile(combined_score.max(), <NUM_LIT>)<EOL>sc = ax.scatter(x=x, y=y, s=area, edgecolors='<STR_LIT>', c=combined_score,<EOL>cmap=cmap, vmin=vmin, vmax=vmax)<EOL>if column in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>xlabel = "<STR_LIT>"%column<EOL><DEDENT>else:<EOL><INDENT>xlabel = column <EOL><DEDENT>ax.set_xlabel(xlabel, fontsize=<NUM_LIT>, fontweight='<STR_LIT>')<EOL>ax.yaxis.set_major_locator(plt.FixedLocator(y))<EOL>ax.yaxis.set_major_formatter(plt.FixedFormatter(ylabels))<EOL>ax.set_yticklabels(ylabels, fontsize=<NUM_LIT:16>)<EOL>ax.grid()<EOL>cax=fig.add_axes([<NUM_LIT>,<NUM_LIT>,<NUM_LIT>,<NUM_LIT>])<EOL>cbar = fig.colorbar(sc, cax=cax,)<EOL>cbar.ax.tick_params(right=True)<EOL>cbar.ax.set_title('<STR_LIT>',loc='<STR_LIT:left>', fontsize=<NUM_LIT:12>)<EOL>if len(df) >= <NUM_LIT:3>:<EOL><INDENT>idx = [area.argmax(), np.abs(area - area.mean()).argmin(), area.argmin()]<EOL>idx = unique(idx)<EOL><DEDENT>else:<EOL><INDENT>idx = df.index.values<EOL><DEDENT>label = df.iloc[idx, df.columns.get_loc('<STR_LIT>')]<EOL>if legend:<EOL><INDENT>handles, _ = ax.get_legend_handles_labels()<EOL>legend_markers = []<EOL>for ix in idx: <EOL><INDENT>legend_markers.append(ax.scatter([],[], s=area[ix], c='<STR_LIT:b>'))<EOL><DEDENT>ax.legend(legend_markers, label, title='<STR_LIT>')<EOL><DEDENT>ax.set_title(title, fontsize=<NUM_LIT:20>, fontweight='<STR_LIT>')<EOL>if ofname is not None: <EOL><INDENT>fig.savefig(ofname, bbox_inches='<STR_LIT>', dpi=<NUM_LIT>)<EOL>return<EOL><DEDENT>return ax<EOL>
Visualize enrichr results.

    :param df: GSEApy DataFrame results.
    :param column: which column of DataFrame to show. Default: Adjusted P-value
    :param title: figure title
    :param cutoff: p-adjust cut-off.
    :param top_term: number of enriched terms to show.
    :param ascending: bool, the order of y axis.
    :param sizes: tuple, (min, max) scatter size. Not functional for now
    :param norm: maplotlib.colors.Normalize object.
    :param legend: bool, whether to show legend.
    :param figsize: tuple, figure size. 
    :param cmap: matplotlib colormap
    :param ofname: output file name. If None, don't save figure