python类set_style()的实例源码

plot-historical-fit.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def init_plotting():
  sns.set_style('whitegrid')

  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (12, 8)
  plt.rcParams['font.size'] = 13
  plt.rcParams['font.family'] = 'OfficinaSanITCBoo'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']
plot-cc-heatmap.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def init_plotting(w,h):
  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (w,h)
  plt.rcParams['font.size'] = 8
  plt.rcParams['font.family'] = 'Source Sans Pro'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']
print-cc-results.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def init_plotting(w,h):
  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (w,h)
  plt.rcParams['font.size'] = 13
  plt.rcParams['font.family'] = 'OfficinaSanITCBoo'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']


# init_plotting(7,4)
plot-cc-strip.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def init_plotting(w,h):
  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (w,h)
  plt.rcParams['font.size'] = 13
  plt.rcParams['font.family'] = 'OfficinaSanITCBoo'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']
plot-color-ts-cc-full.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def init_plotting(w,h):
  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (w,h)
  plt.rcParams['font.size'] = 13
  plt.rcParams['font.family'] = 'OfficinaSanITCBoo'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']
plot-cc-adapt-range.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def init_plotting(w,h):
  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (w,h)
  plt.rcParams['font.size'] = 13
  plt.rcParams['font.family'] = 'OfficinaSanITCBoo'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']
print-cc-full-results.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def init_plotting(w,h):
  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (w,h)
  plt.rcParams['font.size'] = 13
  plt.rcParams['font.family'] = 'OfficinaSanITCBoo'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']


# init_plotting(7,4)
plot-animations.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def init_plotting(w,h):
  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (w,h)
  plt.rcParams['font.size'] = 13
  plt.rcParams['font.family'] = 'OfficinaSanITCBoo'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']
deprecated_seasonal_flu.py 文件源码 项目:augur 作者: nextstrain 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def plot_frequencies(flu, gene, mutation=None, plot_regions=None, all_muts=False, ax=None, **kwargs):
    import seaborn as sns
    sns.set_style('whitegrid')
    cols = sns.color_palette()
    linestyles = ['-', '--', '-.', ':']
    if plot_regions is None:
        plot_regions=regions
    pivots = flu.pivots
    if ax is None:
        plt.figure()
        ax=plt.subplot(111)
    if type(mutation)==int:
        mutations = [x for x,freq in flu.mutation_frequencies[('global', gene)].iteritems()
                     if (x[0]==mutation)&(freq[0]<0.5 or all_muts)]
    elif mutation is not None:
        mutations = [mutation]
    else:
        mutations=None

    if mutations is None:
        for ri, region in enumerate(plot_regions):
            count=flu.mutation_frequency_counts[region]
            plt.plot(pivots, count, c=cols[ri%len(cols)], label=region)
    else:
        print("plotting mutations", mutations)
        for ri,region in enumerate(plot_regions):
            for mi,mut in enumerate(mutations):
                if mut in flu.mutation_frequencies[(region, gene)]:
                    freq = flu.mutation_frequencies[(region, gene)][mut]
                    err = flu.mutation_frequency_confidence[(region, gene)][mut]
                    c=cols[ri%len(cols)]
                    label_str = str(mut[0]+1)+mut[1]+', '+region
                    plot_trace(ax, pivots, freq, err, c=c,
                        ls=linestyles[mi%len(linestyles)],label=label_str, **kwargs)
                else:
                    print(mut, 'not found in region',region)
    ax.ticklabel_format(useOffset=False)
    ax.legend(loc=2)
deprecated_seasonal_flu.py 文件源码 项目:augur 作者: nextstrain 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def plot_sequence_count(flu, fname=None, fs=12):
    # make figure with region counts
    import seaborn as sns
    date_bins = pivots_to_dates(flu.pivots)
    sns.set_style('ticks')
    region_label = {'global': 'Global', 'NA': 'N America', 'AS': 'Asia', 'EU': 'Europe', 'OC': 'Oceania'}
    regions_abbr = ['global', 'NA', 'AS', 'EU', 'OC']
    region_colors = {r:col for r, col in zip(regions_abbr,
                                             sns.color_palette(n_colors=len(regions_abbr)))}
    fig, ax = plt.subplots(figsize=(8, 3))
    count_by_region = flu.mutation_frequency_counts
    drop = 3
    tmpcounts = np.zeros(len(flu.pivots[drop:]))
    plt.bar(date_bins[drop:], count_by_region['global'][drop:], width=18, \
            linewidth=0, label="Other", color="#bbbbbb", clip_on=False)
    for region in region_groups:
        if region!='global':
            plt.bar(date_bins[drop:], count_by_region[region][drop:],
                    bottom=tmpcounts, width=18, linewidth=0,
                    label=region_label[region], color=region_colors[region], clip_on=False)
            tmpcounts += count_by_region[region][drop:]
    make_date_ticks(ax, fs=fs)
    ax.set_ylabel('Sample count')
    ax.legend(loc=3, ncol=1, bbox_to_anchor=(1.02, 0.53))
    plt.subplots_adjust(left=0.1, right=0.82, top=0.94, bottom=0.22)
    sns.despine()
    if fname is not None:
        plt.savefig(fname)
figure.healthy_vs_disease_classifier.py 文件源码 项目:microbiomeHD 作者: cduvallet 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def plot_aucs(aucs, x_col, y_col, groupby_col, colors):
    """
    Scatter plot aucs[x_col] vs aucs[y_col], colored by colors[groupby_col]

    Parameters
    ----------
    aucs : pandas DataFrame
        has x_col, y_col, and groupby_col
    x_col, y_col, groupby_col : str
    colors : dict
        values in groupby_col: color to plot
    """
    sns.set_style('white')
    fig, ax = plt.subplots(figsize=(4,3))
    ax.plot([0, 1], [0, 1], '--', c='0.95')
    ax.plot([0.5, 0.5], [0, 1], '--', c='0.95')
    ax.plot([0, 1], [0.5, 0.5], '--', c='0.95')
    for g, subdf in aucs.groupby(groupby_col):
        if g == 'cdi':
            label = 'diarrhea'
        else:
            label = g.upper()
        ax.scatter(subdf[x_col], subdf[y_col], c=colors[g], label=label)
    ax.set_xlim([0, 1])
    ax.set_ylim([0, 1])
    fig.tight_layout()
    # Shrink current axis by 20%
    box = ax.get_position()
    ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    # Put a legend to the right of the current axis
    lgd = ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
    return fig, ax, lgd
visualize.py 文件源码 项目:arXivTimesIndicator 作者: chakki-works 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def save_bar_graph(x, y, file_name):
    plt.clf()
    sns.set_style("whitegrid")
    ax = sns.barplot(x=x, y=y)
    for item in ax.get_xticklabels():
        item.set_rotation(15)
    plt.savefig(file_name)
visualize.py 文件源码 项目:arXivTimesIndicator 作者: chakki-works 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def save_graph_with_icon(x, y, images, file_name):
    plt.clf()
    sns.set_style("whitegrid")
    ax = sns.barplot(x=x, y=y, ci=None)

    # erase ticks
    ax.get_xaxis().set_ticklabels([], fontsize=45)  # expand label size by fontsize parameter
    TICK_POS = -0.25
    SIZE_IN_TICK = 1

    scale = ax.transData.transform((1, 1)) - ax.transData.transform((0, 0))
    x_scale = scale[0] / scale[1]

    for i, _x in enumerate(x):
        label_x = _x  # adjustment is not needed in saved file
        left = label_x - (SIZE_IN_TICK / x_scale / 2)
        down = TICK_POS - SIZE_IN_TICK
        right = label_x + (SIZE_IN_TICK / x_scale / 2)
        top = TICK_POS
        leftDown = ax.transData.transform((left, down))
        rightUpper = ax.transData.transform((right, top))
        bbox_image = BboxImage(Bbox([leftDown, rightUpper]),
                               norm=None,
                               origin=None,
                               clip_on=False
                               )
        bbox_image.set_data(images[i])
        ax.add_artist(bbox_image)
    plt.savefig(file_name)
kde.py 文件源码 项目:astetik 作者: mikkokotila 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def kde(x,y,title='',color='YlGnBu',xscale='linear',yscale='linear'):

    sns.set_style('white')
    sns.set_context('notebook', font_scale=1, rc={"lines.linewidth": 0.5})
    g = sns.kdeplot(x,y,shade=True, cut=2, cmap=color, shade_lowest=False, legend=True, set_title="test")
    plt.tick_params(axis='both', which='major', pad=10)
    sns.plt.title(title)

    g.set(xscale=xscale)
    g.set(yscale=yscale)

    sns.despine()
regression.py 文件源码 项目:astetik 作者: mikkokotila 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def regression(data,x,y,xscale='linear',yscale='linear'):


    sns.set_context("notebook", font_scale=.8, rc={"lines.linewidth": 0})
    sns.set_style('white')

    g = sns.regplot(x=x, y=y, data=data)

    plt.tick_params(axis='both', which='major', pad=10)

    g.set(xscale=xscale)
    g.set(yscale=yscale)

    sns.despine()
build_page.py 文件源码 项目:datawatch 作者: WideOpen 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def update_graph(dff):
    sns.set_style("white")
    sns.set_style("ticks")

    sns.set_context("talk")
    dff.ix[::10].plot("date", "overdue", figsize=(7, 4), lw=3)
    onemonth = datetime.timedelta(30)
    plt.xlim(dff.date.min(), dff.date.max()+onemonth)
    plt.ylabel("Overdue dataset")
    plt.xlabel("Date")
    plt.savefig("docs/graph.png")
chart.py 文件源码 项目:pygcam 作者: JGCRI 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def setupPlot(context="talk", style="white", font_scale=1.0):
    sns.set_context(context, font_scale=font_scale)
    sns.set_style(style)
Art_class.py 文件源码 项目:artorithmia 作者: alichtner 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def show_image(self):
        """
        Method to plot the image and attributes.

        Input:  None
        Output: None
        """
        print self.__str__()
        sns.set_style("whitegrid", {'axes.grid': False})
        plt.imshow(self.image)
        plt.show()
charting.py 文件源码 项目:jira-metrics-extract 作者: rnwolf 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def set_style(style="darkgrid"):
    sns.set_style(style)
comparisonfigs.py 文件源码 项目:rnnlab 作者: phueb 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def make_probes_ba_traj_fig(models1, models2=None, palette=None):  # TODO ylim
    """
    Returns fig showing trajectory of probes balanced accuracy
    """
    start = time.time()
    sns.set_style('white')
    # load data
    xys = []
    model_groups = [models1] if models2 is None else [models1, models2]
    for n, models in enumerate(model_groups):
        model_probes_ba_trajs = []
        for nn, model in enumerate(models):
            model_probes_ba_trajs.append(model.get_traj('probes_ba'))
        x = models[0].get_data_step_axis()
        traj_mat = np.asarray([traj[:len(x)] for traj in model_probes_ba_trajs])  # all trajs are truncated to shortest
        y = np.mean(traj_mat, axis=0)
        sem = [stats.sem(model_probes_bas) for model_probes_bas in traj_mat.T]
        xys.append((x, y, sem))
    # fig
    fig, ax = plt.subplots(figsize=(FigsConfigs.MAX_FIG_WIDTH, 3))
    ax.set_ylim([50, 75])
    ax.set_xlabel('Mini Batch', fontsize=FigsConfigs.AXLABEL_FONT_SIZE)
    ax.set_ylabel('Probes Balanced Accuracy', fontsize=FigsConfigs.AXLABEL_FONT_SIZE)
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    ax.tick_params(axis='both', which='both', top='off', right='off')
    ax.xaxis.set_major_formatter(FuncFormatter(human_format))
    ax.yaxis.grid(True)
    # plot
    for (x, y, sem) in xys:
        color = next(palette) if palette is not None else 'black'
        ax.plot(x, y, '-', linewidth=FigsConfigs.LINEWIDTH, color=color)
        ax.fill_between(x, np.add(y, sem), np.subtract(y, sem), alpha=FigsConfigs.FILL_ALPHA, color='grey')
    plt.tight_layout()
    print('{} completed in {:.1f} secs'.format(sys._getframe().f_code.co_name, time.time() - start))
    return fig


问题


面经


文章

微信
公众号

扫码关注公众号