Python matplotlib.pylab 模块,rc() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用matplotlib.pylab.rc()

项目:sdp    作者:tansey    | 项目源码 | 文件源码
def plot_1d(dataset, nbins, data):
    with sns.axes_style('white'):
        plt.rc('font', weight='bold')
        plt.rc('grid', lw=2)
        plt.rc('lines', lw=3)
        plt.figure(1)
        plt.hist(data, bins=np.arange(nbins+1), color='blue')
        plt.ylabel('Count', weight='bold', fontsize=24)
        xticks = list(plt.gca().get_xticks())
        while (nbins-1) / float(xticks[-1]) < 1.1:
            xticks = xticks[:-1]
        while xticks[0] < 0:
            xticks = xticks[1:]
        xticks.append(nbins-1)
        xticks = list(sorted(xticks))
        plt.gca().set_xticks(xticks)
        plt.xlim([int(np.ceil(-0.05*nbins)),int(np.ceil(nbins*1.05))])
        plt.legend(loc='upper right')
        plt.savefig('plots/marginals-{0}.pdf'.format(dataset.replace('_','-')), bbox_inches='tight')
        plt.clf()
        plt.close()
项目:sdp    作者:tansey    | 项目源码 | 文件源码
def plot_2d(dataset, nbins, data, extra=None):
    with sns.axes_style('white'):
        plt.rc('font', weight='bold')
        plt.rc('grid', lw=2)
        plt.rc('lines', lw=2)
        rows, cols = nbins
        im = np.zeros(nbins)
        for i in xrange(rows):
            for j in xrange(cols):
                im[i,j] = ((data[:,0] == i) & (data[:,1] == j)).sum()
        plt.imshow(im, cmap='gray_r', interpolation='none')
        if extra is not None:
            dataset += extra
        plt.savefig('plots/marginals-{0}.pdf'.format(dataset.replace('_','-')), bbox_inches='tight')
        plt.clf()
        plt.close()
项目:sdp    作者:tansey    | 项目源码 | 文件源码
def plot_1d(dataset, nbins):
    data = np.loadtxt('experiments/uci/data/splits/{0}_all.csv'.format(dataset), skiprows=1, delimiter=',')[:,-1]
    with sns.axes_style('white'):
        plt.rc('font', weight='bold')
        plt.rc('grid', lw=2)
        plt.rc('lines', lw=3)
        plt.figure(1)
        plt.hist(data, bins=np.arange(nbins+1), color='blue')
        plt.ylabel('Count', weight='bold', fontsize=24)
        xticks = list(plt.gca().get_xticks())
        while (nbins-1) / float(xticks[-1]) < 1.1:
            xticks = xticks[:-1]
        while xticks[0] < 0:
            xticks = xticks[1:]
        xticks.append(nbins-1)
        xticks = list(sorted(xticks))
        plt.gca().set_xticks(xticks)
        plt.xlim([int(np.ceil(-0.05*nbins)),int(np.ceil(nbins*1.05))])
        plt.legend(loc='upper right')
        plt.savefig('plots/marginals-{0}.pdf'.format(dataset.replace('_','-')), bbox_inches='tight')
        plt.clf()
        plt.close()
项目:sdp    作者:tansey    | 项目源码 | 文件源码
def plot_2d(dataset, nbins, data=None, extra=None):
    if data is None:
        data = np.loadtxt('experiments/uci/data/splits/{0}_all.csv'.format(dataset), skiprows=1, delimiter=',')[:,-2:]
    with sns.axes_style('white'):
        plt.rc('font', weight='bold')
        plt.rc('grid', lw=2)
        plt.rc('lines', lw=2)
        rows, cols = nbins
        im = np.zeros(nbins)
        for i in xrange(rows):
            for j in xrange(cols):
                im[i,j] = ((data[:,0] == i) & (data[:,1] == j)).sum()
        plt.imshow(im, cmap='gray_r', interpolation='none')
        if extra is not None:
            dataset += extra
        plt.savefig('plots/marginals-{0}.pdf'.format(dataset.replace('_','-')), bbox_inches='tight')
        plt.clf()
        plt.close()
项目:matplotlib_pubplots    作者:yoachim    | 项目源码 | 文件源码
def mpl_single_column(usetex=False):
    """
    Set matplotlib to make pretty plots for publishing in 2-column
    """
    plt.rcdefaults()
    plt.rc('font', family='serif', size=12.0, style='normal')
    plt.rc('figure', figsize=(4,3))
    plt.rc('axes', titlesize=12, labelsize=10)
    plt.rc('legend', fontsize=8, numpoints=1, scatterpoints=1)
    plt.rc('xtick', labelsize='x-small')
    plt.rc('ytick', labelsize='x-small')
    plt.rc('text', usetex=usetex)
    plt.rc('savefig', format='pdf', bbox='tight')
项目:matplotlib_pubplots    作者:yoachim    | 项目源码 | 文件源码
def mpl_span_columns(usetex=False):
    """
    Set matplotlib to make pretty plots for publishing a full-page figure
    """
    plt.rcdefaults()
    plt.rc('font', family='serif', size=12.0, style='normal')
    plt.rc('figure', figsize=(7, 5.25))
    plt.rc('axes', titlesize=12, labelsize=10)
    plt.rc('legend', fontsize=8, numpoints=1, scatterpoints=1)
    plt.rc('xtick', labelsize='x-small')
    plt.rc('ytick', labelsize='x-small')
    plt.rc('text', usetex=usetex)
    plt.rc('savefig', format='pdf', bbox='tight')
项目:matplotlib_pubplots    作者:yoachim    | 项目源码 | 文件源码
def mpl_slides(usetex=False):
    """
    Set matplotlibrc to make pretty slides
    """
    plt.rcdefaults()
    plt.rc('font', family='serif', size=24)
    # The default PowerPoint page setup
    plt.rc('figure', figsize=(7,5.5))
    plt.rc('axes', titlesize=24, labelsize=20, linewidth=3)
    plt.rc('legend', fontsize=18, numpoints=1, scatterpoints=1)
    plt.rc('xtick', labelsize='small')
    plt.rc('ytick', labelsize='small')
    plt.rc('text', usetex=usetex)
    plt.rc('lines', linewidth=5)
    plt.rc('savefig', format='pdf', bbox='tight')
项目:matplotlib_pubplots    作者:yoachim    | 项目源码 | 文件源码
def mpl_thumbnails(usetex=False):
    """
    Make png thumbnails
    """
    plt.rcdefaults()
    plt.rc('font', family='serif')
    plt.rc('xtick', labelsize='x-small')
    plt.rc('ytick', labelsize='x-small')
    plt.rc('text', usetex=usetex)
    plt.rc('savefig', format='pdf', bbox='tight')
    plt.rc('savefig', format='png', bbox='tight')
    plt.rc('figure', figsize=(4,3))
项目:Trending-Places-in-OpenStreetMap    作者:geometalab    | 项目源码 | 文件源码
def plot_graphs(df, trending_daily, day_from, day_to, limit, country_code, folder_out=None):
    days = pd.DatetimeIndex(start=day_from, end=day_to, freq='D')
    for day in days:
        fig = plt.figure()
        ax = fig.add_subplot(111)
        plt.rc('lines', linewidth=2)
        data = trending_daily.get_group(str(day.date()))
        places, clusters = top_trending(data, limit)
        for cluster in clusters:
            places.add(max_from_cluster(cluster, data))
        ax.set_prop_cycle(plt.cycler('color', ['r', 'b', 'yellow'] + [plt.cm.Accent(i) for i in np.linspace(0, 1, limit-3)]
                                     ) + plt.cycler('linestyle', ['-', '-', '-', '-', '-', '--', '--', '--', '--', '--']))
        frame = export(places, clusters, data)
        frame.sort_values('trending_rank', ascending=False, inplace=True)
        for i in range(len(frame)):
            item = frame.index[i]
            lat, lon, country = item
            result_items = ReverseGeoCode().get_address_attributes(lat, lon, 10, 'city', 'country_code')
            if 'city' not in result_items.keys():
                mark = "%s (%s)" % (manipulate_display_name(result_items['display_name']),
                                    result_items['country_code'].upper() if 'country_code' in result_items.keys() else country)
            else:
                if check_eng(result_items['city']):
                    mark = "%s (%s)" % (result_items['city'], result_items['country_code'].upper())
                else:
                    mark = "%.2f %.2f (%s)" % (lat, lon, result_items['country_code'].upper())
            gp = df.loc[item].plot(ax=ax, x='date', y='count', label=mark)
        ax.tick_params(axis='both', which='major', labelsize=10)
        ax.set_yscale("log", nonposy='clip')
        plt.xlabel('Date', fontsize='small', verticalalignment='baseline', horizontalalignment='right')
        plt.ylabel('Total number of views (log)', fontsize='small', verticalalignment='center', horizontalalignment='center', labelpad=6)
        gp.legend(loc='best', fontsize='xx-small', ncol=2)
        gp.set_title('Top 10 OSM trending places on ' + str(day.date()), {'fontsize': 'large', 'verticalalignment': 'bottom'})
        plt.tight_layout()
        db = TrendingDb()
        db.update_table_img(plt, str(day.date()), region=country_code)
        plt.close()