当前位置: 首页>>代码示例>>Python>>正文


Python font_manager.FontProperties类代码示例

本文整理汇总了Python中matplotlib.font_manager.FontProperties的典型用法代码示例。如果您正苦于以下问题:Python FontProperties类的具体用法?Python FontProperties怎么用?Python FontProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FontProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():

    # Write a part to put image directories into "groups"
    source_dirs = [
        '/home/sbraden/400mpp_15x15_clm_wac/mare/',
        '/home/sbraden/400mpp_15x15_clm_wac/pyro/',
        '/home/sbraden/400mpp_15x15_clm_wac/imps/',
        '/home/sbraden/400mpp_15x15_clm_wac/mare_immature/'
        ]

    for directory in source_dirs:
        
        print directory
        groupname = os.path.split(os.path.dirname(directory))[1]
        print groupname
        # read in LROC WAC images
        wac_img_list = iglob(directory+'*_wac.cub')
        # read in Clementine images
        clm_img_list = iglob(directory+'*_clm.cub')

        make_cloud_plot(wac_img_list, colorloop.next(), groupname)

    fontP = FontProperties()
    fontP.set_size('small')
    #plt.legend(loc='upper left', fancybox=True, prop=fontP, scatterpoints=1)
    #plt.axis([0.70, 0.86, 0.90, 1.15],fontsize=14)
    plt.axis([0.60, 0.90, 0.90, 1.20],fontsize=14)
    plt.axes().set_aspect('equal')
    # THIS next line does not get called:
    plt.margins(0.20) # 4% add "padding" to the data limits before they're autoscaled
    plt.xlabel('WAC 320/415 nm', fontsize=14)
    plt.ylabel('CLM 950/750 nm', fontsize=14)
    plt.savefig('lunar_roi_cloud_plot.png', dpi=300)
    plt.close()
开发者ID:sbraden,项目名称:pysis-scripts,代码行数:34,代码来源:cube_to_cloudplot.py

示例2: test_suptitle_fontproperties

def test_suptitle_fontproperties():
    from matplotlib.font_manager import FontProperties
    fig, ax = plt.subplots()
    fps = FontProperties(size='large', weight='bold')
    txt = fig.suptitle('fontprops title', fontproperties=fps)
    assert txt.get_fontsize() == fps.get_size_in_points()
    assert txt.get_weight() == fps.get_weight()
开发者ID:JIE2016G,项目名称:matplotlib,代码行数:7,代码来源:test_figure.py

示例3: __init__

    def __init__(self, xy, s, size=None, prop=None,
                 _interpolation_steps=1, usetex=False,
                 *kl, **kwargs):
        """
        Create a path from the text. No support for TeX yet. Note that
        it simply is a path, not an artist. You need to use the
        PathPatch (or other artists) to draw this path onto the
        canvas.

        xy : position of the text.
        s : text
        size : font size
        prop : font property
        """

        if prop is None:
            prop = FontProperties()

        if size is None:
            size = prop.get_size_in_points()

        self._xy = xy
        self.set_size(size)

        self._cached_vertices = None

        self._vertices, self._codes = self.text_get_vertices_codes(
                                            prop, s,
                                            usetex=usetex)

        self._should_simplify = False
        self._simplify_threshold = rcParams['path.simplify_threshold']
        self._has_nonfinite = False
        self._interpolation_steps = _interpolation_steps
开发者ID:WarrenWeckesser,项目名称:matplotlib,代码行数:34,代码来源:textpath.py

示例4: plot_gradient_over_time

def plot_gradient_over_time(points, get_grad_over_time):
    fig = plt.figure(figsize=(6.5, 4))
    # Remove the plot frame lines. They are unnecessary chartjunk.    
    ax = plt.subplot(111)    
    ax.spines["top"].set_visible(False)
    ax.spines["right"].set_visible(False)
    # ax.xaxis.set_major_locator(plt.MultipleLocator(1.0))
    # ax.xaxis.set_minor_locator(plt.MultipleLocator(0.1))
    # ax.yaxis.set_major_locator(plt.MultipleLocator(1.0))
    # ax.yaxis.set_minor_locator(plt.MultipleLocator(0.1))
    # ax.grid(which='major', axis='x', linewidth=0.75, linestyle='-', color='0.75')
    # ax.grid(which='minor', axis='x', linewidth=0.25, linestyle='-', color='0.75')
    # ax.grid(which='major', axis='y', linewidth=0.75, linestyle='-', color='0.75')
    # ax.grid(which='minor', axis='y', linewidth=0.25, linestyle='-', color='0.75')
    ax.grid(b=True, which='major', linewidth=0.75, linestyle=':', color='0.75')
    ax.yaxis.set_ticks_position('none')
    ax.xaxis.set_ticks_position('none')
    for wx, wRec, c in points:
        grad_over_time = get_grad_over_time(wx, wRec)
        x = np.arange(1, grad_over_time.shape[1]+1, 1)
        plt.plot(x, np.sum(grad_over_time, axis=0), c+'.-', label='({0}, {1})'.format(wx, wRec), linewidth=1, markersize=8)
    plt.xlim(1, grad_over_time.shape[1])
    plt.xticks(x)
    plt.gca().invert_xaxis()
    plt.yscale('symlog')
    plt.yticks([10**8, 10**6, 10**4, 10**2, 0, -10**2, -10**4, -10**6, -10**8])
    plt.xlabel('time k')
    plt.ylabel('gradient ')
    plt.title('Unstability of gradient in backward propagation.\n(backpropagate from left to right)')
    leg = plt.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=False, numpoints=1)
    leg_font = FontProperties()
    leg_font.set_size('x-large')
    leg.set_title('$(w_x, w_{rec})$', prop=leg_font)
开发者ID:Sandy4321,项目名称:peterroelants.github.io,代码行数:33,代码来源:plot_utils.py

示例5: plot_all

def plot_all(wells, errors=None, do_legend=True, legend_position=0.8):
    """Plots all of the timecourses in the dict.

    Parameters
    ----------
    wells : dict of timecourse data of the type returned by read_wallac.
    """
    for wellname, wellval in wells.iteritems():
        if errors is None:
            plot(wellval[TIME], wellval[VALUE], label=wellname)
        else:
            errorbar(wellval[TIME], wellval[VALUE],
                    yerr=errors[wellname][VALUE], label=wellname)

    # Label the axes and add a legend
    xlabel('Time') # TODO: automatically determine seconds or minutes, etc.
    ylabel('Value')

    if do_legend:
        fontP = FontProperties()
        fontP.set_size('small')
        ax = gca()
        box = ax.get_position()
        ax.set_position([box.x0, box.y0, box.width * legend_position,
                         box.height])
        legend(loc='upper left', prop=fontP, ncol=1, bbox_to_anchor=(1, 1),
             fancybox=True, shadow=True)
开发者ID:johnbachman,项目名称:tBidBaxLipo,代码行数:27,代码来源:plate_assay.py

示例6: ageGrade_hist

def ageGrade_hist(results,title=None,style='bmh'):
    '''
    Draw an histogram of the Age Grade results with basic stats added in the corner
    '''
    # reset style first (if style has been changed before running the script)
    plt.style.use('classic')
    plt.style.use(style)
    plt.style.use(r'.\large_font.mplstyle')
        
    fig, ax = plt.subplots(figsize=(10,8))
    ax.hist(results['Age Grade']*100,bins=np.arange(0,100,5),color='#A60628')
    #ax.set_xlim(15,60)
    ax.set_xlabel('Age Grade %',size='x-large')
    #ax.set_ylim(0,40)
    ax.set_ylabel('Count',size='x-large')
    plt.title(title)
    
    # add stats in a box
    stats = results['Age Grade'].describe()
    stats.iloc[1:]=stats.iloc[1:]*100
    stats_text = "Count  = {:.0f}\nMean   = {:.1f}%\nMedian = {:.1f}%" +\
                "\nMin    = {:.1f}%\nMax    = {:.1f}%"
    stats_text = stats_text.format(stats['count'],
                                   stats['mean'],stats['50%'],
                                   stats['min'],stats['max'])
    font0 = FontProperties()
    font0.set_family('monospace')
    ax.text(0.72,0.75,stats_text,fontsize=14,fontproperties=font0,
            bbox=dict(facecolor='white'),transform=ax.transAxes)
开发者ID:jobar8,项目名称:parkrun,代码行数:29,代码来源:parkrun.py

示例7: _show_3d_plot

 def _show_3d_plot(self):
     '''
     Shows the plot using pylab.  Usually I won't do imports in methods,
     but since plotting is a fairly expensive library to load and not all 
     machines have matplotlib installed, I have done it this way.
     '''
     import matplotlib.pyplot as plt
     import mpl_toolkits.mplot3d.axes3d as p3
     from matplotlib.font_manager import FontProperties
     fig = plt.figure()
     ax = p3.Axes3D(fig)
     font = FontProperties()
     font.set_weight('bold')
     font.set_size(20)
     (lines, labels, unstable) = self.pd_plot_data
     count = 1
     newlabels = list()
     for x, y, z in lines:
         ax.plot(x, y, z, 'bo-', linewidth=3, markeredgecolor='b', markerfacecolor='r', markersize=10)
     for coords in sorted(labels.keys()):
         entry = labels[coords]
         label = entry.name
         if len(entry.composition.elements) == 1:
             # commented out options are only for matplotlib 1.0.  Removed them so that most ppl can use this class.
             ax.text(coords[0], coords[1], coords[2], label)#, horizontalalignment=halign, verticalalignment=valign, fontproperties=font)
         else:
             ax.text(coords[0], coords[1], coords[2], str(count))#, horizontalalignment=halign, verticalalignment=valign, fontproperties=font)
             newlabels.append(str(count) + " : " + label)
             count += 1
     plt.figtext(0.01, 0.01, '\n'.join(newlabels))
     ax.axis('off')
     plt.show()
开发者ID:chenweis,项目名称:pymatgen,代码行数:32,代码来源:plotter.py

示例8: PlotSensitivityAndPPVGraphs

def PlotSensitivityAndPPVGraphs(sensitivityDict, ppvDict, graphTitle, xAxisTitle, index, graphFileName):
	
	sensDremeMeanValues, sensDremeErrorValues, sensKspectrumMeanValues, sensKspectrumErrorValues, labels = parseResults.GetMeanAndStdErrorValues(sensitivityDict, index);
	ppvDremeMeanValues, ppvDremeErrorValues, ppvKspectrumMeanValues, ppvKspectrumErrorValues, labels = parseResults.GetMeanAndStdErrorValues(ppvDict, index);

	import matplotlib
	matplotlib.use('Agg')
	
	from matplotlib import pyplot as plt	
	matplotlib.rcParams.update({'font.size': 8})

	#Two subplots, the axes array is 1-d
	fig, (ax1, ax2) = plt.subplots(nrows=2)
	eb1, eb2, eb3, eb4 = sensitivity_ppv_plot(ax1, graphTitle + " on Sensitivity", sensDremeMeanValues, sensDremeErrorValues, sensKspectrumMeanValues, sensKspectrumErrorValues, labels, xAxisTitle, "Sensitivity");
	eb1, eb2, eb3, eb4= sensitivity_ppv_plot(ax2, graphTitle + " on PPV", ppvDremeMeanValues, ppvDremeErrorValues, ppvKspectrumMeanValues, ppvKspectrumErrorValues, labels, xAxisTitle, "PPV");	

	#ax2.set_xlabel(xAxisTitle)

	handles_ax1, labels_ax1 = ax1.get_legend_handles_labels();
	handles_ax1 = [h[0] for h in handles_ax1];

	from matplotlib.font_manager import FontProperties
	fontP = FontProperties();
	fontP.set_size('small');
	#fig.legend([eb1, eb2, eb3, eb4], ["DREME", "k-spectrum-25", "k-spectrum-50", "k-spectrum-100"], prop = fontP)
	fig.legend(handles_ax1, labels_ax1, loc = 'upper right')
	plt.savefig(graphFileName);
	plt.close(fig)
开发者ID:shwetabhandare,项目名称:PySG,代码行数:28,代码来源:generateGraphs.py

示例9: save_graph

def save_graph(go_dict, chart_type, level, parser):
	fontP = FontProperties()
	fontP.set_size('small')
	# The slices will be ordered and plotted counter-clockwise.
	figure = plt.figure(figsize=(10,10))
	
	labels = go_dict.keys()
	sizes = [parser.go_term_by_name_dict.get(x)[0].encountered_count for x in go_dict]
	#sizes = go_dict.values() 	
	#print (chart_type)
	#print (zip(labels, sizes))
	#print (sum(sizes))
	plt.title('Graph Level %s Pie Chart [%s]' % (level, chart_type))
	total = sum(sizes)
	
	labels = [l+" "+str(float(s)/total * 100)[0:4]+"%  ("+ str(s) + ")" for l,s in zip(labels, sizes)]

	patches, texts = plt.pie(sizes, startangle=90)
	plt.legend(patches, labels, prop = fontP, loc="best")
	# Set aspect ratio to be equal so that pie is drawn as a circle.
	plt.axis('equal')
	#plt.tight_layout()
	#plt.show()



	print (chart_type)
	out = [str(x) + "\t" + str(parser.go_term_by_name_dict.get(x)[0].encountered_count) for x in go_dict]

	for x in out:
		print (x)
	print ("\n")	


	figure.savefig(chart_type+"_level_"+level+'.png',aspect='auto',dpi=100)
开发者ID:SamGinzburg,项目名称:GeneOntologyTools,代码行数:35,代码来源:generate_pie_charts.py

示例10: plot_benchmarks

def plot_benchmarks(runs, out_file="output.eps", dpi=1200):
    from matplotlib import pyplot as plt
    from matplotlib.font_manager import FontProperties

    fontP = FontProperties()
    fontP.set_size("small")

    lines, densities = regroup_runs(runs)

    for line in lines:
        method = line["method"]
        condensation = line["2x2"]
        ys = [line[x] for x in densities]

        plt.plot(
            densities,
            ys,
            METHOD_SHAPE[method] + COND_SHAPE[condensation],
            color=METHOD_COLOR[method],
            label=method + COND_LEGEND[condensation],
        )

    plt.xlabel("density, %")
    plt.ylabel("CPU time, ms")

    if "2000" not in out_file:
        lgd = plt.legend(loc=2, prop=fontP)
    else:
        lgd = plt.legend(loc=2, bbox_to_anchor=(1, 1), prop=fontP)
    plt.grid(True)
    plt.savefig(out_file, bbox_extra_artists=(lgd,), bbox_inches="tight", format=out_file[-3:], dpi=dpi)
开发者ID:moskupols,项目名称:image-labeling-benchmark,代码行数:31,代码来源:csv-to-latex.py

示例11: graph

def graph(fil):
    heap, time , free = np.loadtxt(fil, delimiter=',', unpack=True)

    fig,ax1 = plt.subplots(dpi=120, figsize=(7,7))
    ax2 = plt.twinx()

    ax1.set_ylabel("Allocation time ($ms$)",color = 'blue')
    ax1.set_xlabel("Initial heap size ($MB$)")

    ax2.set_ylabel("Free space on heap ($MB$)",color = 'green')
    ax2.set_xlabel("Initial heap size ($MB$)")


    p1,= ax1.plot(heap,time, label='Time taken to allocate large array')
    p2,= ax2.plot(heap,free , label='Free space on heap' ,color = 'green')


    plt.title('Scala Fragmentation tolerance')

    from matplotlib.font_manager import FontProperties
    fontP = FontProperties()
    fontP.set_size('small')


    lines =[p1,p2]

    plt.legend(lines, [l.get_label() for l in lines],prop = fontP ,loc =9)

    name =  fil.split('.')[0]
    name = name +".png"

    plt.savefig(name)
开发者ID:UBMLtonGroup,项目名称:rt-benchmarks,代码行数:32,代码来源:gengraphs.py

示例12: topic_distribution

def topic_distribution(name = None, study = None, order = None, **options):
    '''Given a model p_z,p_w_z,p_d_z, we can plot the document's distribution
    using p(z|d) = normalized((p(d|z)*p(z))) '''
    
    m = microbplsa.MicrobPLSA()
    m.open_model(name = name, study = study, **options) #get model from the results file
    #return document's distribution
    p_z_d = m.model.document_topics()
    
    Z,N =p_z_d.shape #number of samples
    if order is not None:
        p_z_d = p_z_d[:,order]
    n = np.arange(N)
    width = 25.0/float(N) #scale width of bars by number of samples
    p = [] #list of plots
    colors = plt.cm.rainbow(np.linspace(0, 1, Z))    
    
    Lab = Labelling(m, ignore_continuous = False)
    Lab.metadata(non_labels = ['BarcodeSequence'])
    R = Lab.correlate()
    labels_r = Lab.assignlabels(R,num_labels = 1)
    labels, r = zip(*labels_r)
    labels = [l.replace('(','\n(') for l in labels]
    
    #sort and organize labels and topics so they are always plotted in the same order
    labelsUnsorted = zipper(labels,range(0,Z))
    labelsUnsorted.sort()
    labels, Zrange = zip(*labelsUnsorted)
    Zrange = list(Zrange)
    p.append(plt.bar(n, p_z_d[Zrange[0],:], width, color=colors[0], linewidth = 0))
    height = p_z_d[Zrange[0],:]
    for i,z in enumerate(Zrange[1:]):
        p.append(plt.bar(n, p_z_d[z,:], width, color=colors[i+1], bottom=height, linewidth = 0))
        height += p_z_d[z,:]
    
    
    plt.ylabel('Probability P(z|d)')
    plt.xlabel('Sample')
    plt.title('Sample\'s topic distribution')
    #plt.xticks(np.arange(0,width/2.0,N*width), ['S'+str(n) for n in range(1,N)])

    topiclegend = ['Topic' + str(Zrange[labels.index(l)]+1) + ': '+ l + '\n ('+ str(r[Zrange[labels.index(l)]]) + ')' for l in labels]
    fontP = FontProperties()
    if N >60:
        fontP.set_size('xx-small')
    else: fontP.set_size('small')
    ax = plt.subplot(111)
    ratio = float(N)*0.5
    ax.set_aspect(ratio)
    ax.tick_params(axis = 'x', colors='w') #remove tick labels by setting them the same color as background
    box = ax.get_position()
    ax.set_position([box.x0, box.y0, 0.5, box.height])

    if order is not None:
        plt.xticks(n, order, size = 'xx-small')
    if Z > 12: 
        columns = 2
    else: columns = 1
    plt.legend(p, topiclegend, prop = fontP, title = 'Topic Label', loc='center left', bbox_to_anchor=(1, 0.5), ncol = columns)
    return plt
开发者ID:sperez8,项目名称:microbPLSA,代码行数:60,代码来源:microbPlotter.py

示例13: make_cross_plot

def make_cross_plot(wac_df, clm_df):
    '''
    x = 320/415
    y = 950/750
    '''

    for index_name in wac_df.index:
        roi_name = index_name[:-4]
        x = wac_df.loc[index_name].values
        y = clm_df.loc[roi_name+'_clm'].values
        x_data = np.ma.masked_array(x[0],np.isnan(x[0]))
        y_data = np.ma.masked_array(y[0],np.isnan(y[0]))
        print roi_name, np.mean(x_data), np.mean(y_data), np.std(x_data), np.std(y_data)
        plt.errorbar(np.mean(x_data), np.mean(y_data), xerr=np.std(x_data),
            yerr=np.std(y_data), marker='o', label=(roi_name), 
            c=colorloop.next())

    rois_rough = pd.read_csv('/home/sbraden/imps_ratio_rough.csv', index_col=0)
    rois_mare = pd.read_csv('/home/sbraden/imps_ratio_mare.csv', index_col=0)

    for roi_name in rois_rough.index:
        ratio = rois_rough.loc[roi_name].values
        plt.scatter(ratio[1], ratio[0], marker='s', c='blue')
    
    for roi_name in rois_mare.index:
        ratio = rois_mare.loc[roi_name].values
        plt.scatter(ratio[1], ratio[0], marker='s', c='red')

    fontP = FontProperties()
    fontP.set_size('small')
    plt.legend(loc='lower right', prop=fontP, numpoints=1)
    plt.xlabel('320/415 nm WAC ratio', fontsize=14)
    plt.ylabel('950/750 nm CLEM ratio', fontsize=14)
    plt.savefig('lunar_roi_cross_plot.png', dpi=300)
    plt.close()
开发者ID:sbraden,项目名称:pysis-scripts,代码行数:35,代码来源:cube_to_cloudplot.py

示例14: create_plot

def create_plot(plot_title, datasets, offset, count, output_path):
    x = 0

    for dataset_path in datasets:

        first,average,conf = statistics(dataset_path, offset, count)

        b_first = plt.bar(x, first, 0.5, color='b')
        x += 0.5

        b_average = plt.bar(x, average, 0.5, color='r', yerr=conf, ecolor='black')
        x += 1.5

    plt.title("benchmark: " + plot_title)

    plt.xlabel('Dataset', fontsize=12)
    plt.ylabel('Time', fontsize=12)

    plt.xticks([0.5, 2.5, 4.5, 6.5, 8.5], ['10', '100', '1000', '10000', '100000'], rotation='horizontal')

    # Create graph legend
    fontP = FontProperties()
    fontP.set_size('small')

    plt.legend([b_first, b_average], \
        ('first query time', 'average time of other queries'), \
        prop=fontP, loc='upper center', bbox_to_anchor=(0.5, -0.05), fancybox=True, shadow=True, ncol=2)
    
    # Plot to file
    plt.savefig(output_path)
    plt.clf()
开发者ID:SuperV1234,项目名称:db2,代码行数:31,代码来源:make_plots.py

示例15: add_plot

    def add_plot(title, plots, min_class_label, max_class_label):
        colors = ["r", "y"]
        place = [0, 0.35]

        Utils.subplot += 1
        # fig = .figure()
        ax = Utils.figure.add_subplot(Utils.subplot)

        Utils.figure.subplots_adjust(hspace=0.75, wspace=0.5)
        ax.set_title(title)
        ax.set_xticks(np.arange(8))
        for i in xrange(len(plots)):
            item = plots[i]
            if item["xlim"] != None:
                ax.set_xlim(item["xlim"])
            if item["ylim"] != None:
                ax.set_ylim(item["ylim"])
            ax.set_xlabel(item["xlabel"])
            ax.set_ylabel(item["ylabel"])
            ax.bar(
                np.arange(min_class_label, max_class_label + 1) + place[i],
                item["y_values"],
                0.35,
                color=colors[i],
                label=item["label"],
            )

        handles, labels = ax.get_legend_handles_labels()
        fontP = FontProperties()
        fontP.set_size("small")
        Utils.figure.legend(handles, labels, loc="upper right", prop=fontP)
开发者ID:meyyar,项目名称:WoC,代码行数:31,代码来源:utils.py


注:本文中的matplotlib.font_manager.FontProperties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。