def barplot(df, column='Adjusted P-value', title="", cutoff=0.05, top_term=10,
            figsize=(6.5,6), color='salmon', ofname=None, **kwargs):
    """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: cut-off of the cloumn you've chosen.
    :param top_term: number of top enriched terms to show.
    :param figsize: tuple, matplotlib figsize.
    :param color: color for bars.
    :param ofname: output file name. If None, don't save figure    
    
    """

    colname = column   
    if colname in ['Adjusted P-value', 'P-value']: 
        df = df[df[colname] <= cutoff]
        if len(df) < 1: 
            msg = "Warning: No enrich terms using library %s when cutoff = %s"%(title, cutoff)
            return msg
        df = df.assign(logAP = lambda x: - x[colname].apply(np.log10))
        colname = 'logAP' 
    dd = df.sort_values(by=colname).iloc[-top_term:,:]
    # dd = d.head(top_term).sort_values('logAP')
    # create bar plot
    if hasattr(sys, 'ps1') and (ofname is None):
        # working inside python console, show (True) figure
        fig = plt.figure(figsize=figsize)
    else:
        # If working on commandline, don't show figure
        fig = Figure(figsize=figsize)
        canvas = FigureCanvas(fig)
    ax = fig.add_subplot(111)
    bar = dd.plot.barh(x='Term', y=colname, color=color, 
                       alpha=0.75, fontsize=16, ax=ax)
    
    if column in ['Adjusted P-value', 'P-value']:
        xlabel = "-log$_{10}$(%s)"%column
    else:
        xlabel = column 
    bar.set_xlabel(xlabel, fontsize=16, fontweight='bold')
    bar.set_ylabel("")
    bar.set_title(title, fontsize=24, fontweight='bold')
    bar.xaxis.set_major_locator(MaxNLocator(integer=True))
    bar.legend_.remove()
    adjust_spines(ax, spines=['left','bottom'])

    if ofname is not None: 
        # canvas.print_figure(ofname, bbox_inches='tight', dpi=300)
        fig.savefig(ofname, bbox_inches='tight', dpi=300)
        return
    return ax
def barplot(df, column='Adjusted P-value', title="", cutoff=0.05, top_term=10,
            figsize=(6.5,6), color='salmon', ofname=None, **kwargs):
    """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: cut-off of the cloumn you've chosen.
    :param top_term: number of top enriched terms to show.
    :param figsize: tuple, matplotlib figsize.
    :param color: color for bars.
    :param ofname: output file name. If None, don't save figure    
    
    """

    colname = column   
    if colname in ['Adjusted P-value', 'P-value']: 
        df = df[df[colname] <= cutoff]
        if len(df) < 1: 
            msg = "Warning: No enrich terms using library %s when cutoff = %s"%(title, cutoff)
            return msg
        df = df.assign(logAP = lambda x: - x[colname].apply(np.log10))
        colname = 'logAP' 
    dd = df.sort_values(by=colname).iloc[-top_term:,:]
    # dd = d.head(top_term).sort_values('logAP')
    # create bar plot
    if hasattr(sys, 'ps1') and (ofname is None):
        # working inside python console, show (True) figure
        fig = plt.figure(figsize=figsize)
    else:
        # If working on commandline, don't show figure
        fig = Figure(figsize=figsize)
        canvas = FigureCanvas(fig)
    ax = fig.add_subplot(111)
    bar = dd.plot.barh(x='Term', y=colname, color=color, 
                       alpha=0.75, fontsize=16, ax=ax)
    
    if column in ['Adjusted P-value', 'P-value']:
        xlabel = "-log$_{10}$(%s)"%column
    else:
        xlabel = column 
    bar.set_xlabel(xlabel, fontsize=16, fontweight='bold')
    bar.set_ylabel("")
    bar.set_title(title, fontsize=24, fontweight='bold')
    bar.xaxis.set_major_locator(MaxNLocator(integer=True))
    bar.legend_.remove()
    adjust_spines(ax, spines=['left','bottom'])

    if ofname is not None: 
        # canvas.print_figure(ofname, bbox_inches='tight', dpi=300)
        fig.savefig(ofname, bbox_inches='tight', dpi=300)
        return
    return ax
def barplot ( df , column = 'Adjusted P-value' , title = "" , cutoff = 0.05 , top_term = 10 , figsize = ( 6.5 , 6 ) , color = 'salmon' , ofname = None , * * kwargs ) : colname = column if colname in [ 'Adjusted P-value' , 'P-value' ] : df = df [ df [ colname ] <= cutoff ] if len ( df ) < 1 : msg = "Warning: No enrich terms using library %s when cutoff = %s" % ( title , cutoff ) return msg df = df . assign ( logAP = lambda x : - x [ colname ] . apply ( np . log10 ) ) colname = 'logAP' dd = df . sort_values ( by = colname ) . iloc [ - top_term : , : ] # dd = d.head(top_term).sort_values('logAP') # create bar plot if hasattr ( sys , 'ps1' ) and ( ofname is None ) : # working inside python console, show (True) figure fig = plt . figure ( figsize = figsize ) else : # If working on commandline, don't show figure fig = Figure ( figsize = figsize ) canvas = FigureCanvas ( fig ) ax = fig . add_subplot ( 111 ) bar = dd . plot . barh ( x = 'Term' , y = colname , color = color , alpha = 0.75 , fontsize = 16 , ax = ax ) if column in [ 'Adjusted P-value' , 'P-value' ] : xlabel = "-log$_{10}$(%s)" % column else : xlabel = column bar . set_xlabel ( xlabel , fontsize = 16 , fontweight = 'bold' ) bar . set_ylabel ( "" ) bar . set_title ( title , fontsize = 24 , fontweight = 'bold' ) bar . xaxis . set_major_locator ( MaxNLocator ( integer = True ) ) bar . legend_ . remove ( ) adjust_spines ( ax , spines = [ 'left' , 'bottom' ] ) if ofname is not None : # canvas.print_figure(ofname, bbox_inches='tight', dpi=300) fig . savefig ( ofname , bbox_inches = 'tight' , dpi = 300 ) return return ax
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: cut-off of the cloumn you've chosen.
    :param top_term: number of top enriched terms to show.
    :param figsize: tuple, matplotlib figsize.
    :param color: color for bars.
    :param ofname: output file name. If None, don't save figure
Visualize enrichr results .