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


Python FontProperties.set_weight方法代码示例

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


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

示例1: _show_3d_plot

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
 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,代码行数:34,代码来源:plotter.py

示例2: format_plot

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
def format_plot(axes, xlim=None, ylim=None, xlabel='', ylabel=''):
    '''format 2d-plot black and with with times legends 
    '''
    #-------------------------------------------------------------------
    # configure the style of the font to be used for labels and ticks
    #-------------------------------------------------------------------
    #
    from matplotlib.font_manager import FontProperties
    font = FontProperties()
    font.set_name('Script MT')
    font.set_family('serif')
    font.set_style('normal')
#    font.set_size('small')
    font.set_size('large')
    font.set_variant('normal')
    font.set_weight('medium')
    
    if xlim != None and ylim != None:
        axes.axis([0, xlim, 0., ylim], fontproperties=font)

    # format ticks for plot
    #
    locs, labels = axes.xticks()
    axes.xticks(locs, map(lambda x: "%.0f" % x, locs), fontproperties=font)
    axes.xlabel(xlabel, fontproperties=font)

    locs, labels = axes.yticks()
    axes.yticks(locs, map(lambda x: "%.0f" % x, locs), fontproperties=font)
    axes.ylabel(ylabel, fontproperties=font)
开发者ID:sarosh-quraishi,项目名称:simvisage,代码行数:31,代码来源:show_results.py

示例3: main

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
def main():
    """GO!"""
    font0 = FontProperties()
    font0.set_weight('bold')

    # email from Javed dated Sep 22, 2016
    df = pd.read_excel("/tmp/ames.xlsx")

    (fig, ax) = plt.subplots(1, 1)

    for _, row in df.iterrows():
        c = 'r' if row['Year'] in [2011, 2012, 2013] else 'k'
        c = 'g' if row['Year'] in [1980, 1992, 1993] else c
        ax.text(row['t'], row['p'], ("%i" % (row['Year'],))[-2:], color=c,
                ha='center')

    ax.set_xlim(df['t'].min() - 0.3, df['t'].max() + 0.3)
    ax.set_ylim(df['p'].min() - 10, df['p'].max() + 10)
    ax.set_xlabel(r"Average Temperature ($^\circ$C)")
    ax.set_ylabel("Cumulative Precipitation (cm)")

    ax.text(0.15, 0.95, "Cool & Wet", ha='center', transform=ax.transAxes,
            fontproperties=font0)
    ax.text(0.85, 0.95, "Warm & Wet", ha='center', transform=ax.transAxes,
            fontproperties=font0)
    ax.text(0.85, 0.05, "Warm & Dry", ha='center', transform=ax.transAxes,
            fontproperties=font0)
    ax.text(0.15, 0.05, "Cool & Dry", ha='center', transform=ax.transAxes,
            fontproperties=font0)
    ax.axhline(df['p'].mean())
    ax.axvline(df['t'].mean())

    fig.savefig('test.pdf', dpi=300)
开发者ID:akrherz,项目名称:DEV,代码行数:35,代码来源:fourquad.py

示例4: plot_triangle

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
    def plot_triangle(self):
        
        font_ = FontProperties()
        font_.set_family('sans-serif')
        font_.set_weight('normal')
        font_.set_style('italic')
        self.fig = figure()
        alpha = 0.8
        alphal = 0.5
        third_range = np.linspace(-0.0277, 0.21, 10000)
        second_upper = 2*third_range + 2.0/9.0
        plot(third_range, second_upper, color='k', alpha=alphal)
        
        second_right = 1.5*(abs(third_range)*4.0/3.0)**(2.0/3.0)
        plot(third_range, second_right, color='k', alpha=alphal)
        connectionstyle="arc3,rad=.1"
        lw = 0.5
        plot(np.array([0.0, 0.0]), np.array([0.0, 2.0/9.0]), color='k', alpha=alphal)
        gca().annotate(r'Isotropic limit', xy=np.array([0, 0]), xytext=np.array([0.05, 0.02]), fontproperties=font_, rotation=0, alpha=alpha, arrowprops=dict(arrowstyle="->", connectionstyle=connectionstyle, lw=lw))
        gca().annotate(r'Plane strain', xy=np.array([0, 1.0/9.0/2]), xytext=np.array([0.07, 0.07]), fontproperties=font_, rotation=0, alpha=alpha, arrowprops=dict(arrowstyle="->", connectionstyle=connectionstyle, lw=lw))
        gca().annotate(r'One component limit', xy=np.array([third_range[-1], second_upper[-1]]), xytext=np.array([0.00, 0.6]), fontproperties=font_, rotation=0, alpha=alpha, arrowprops=dict(arrowstyle="->", connectionstyle=connectionstyle, lw=lw))
        gca().annotate(r'Axisymmetric contraction', xy=np.array([third_range[1000/2], second_right[1000/2]]), xytext=np.array([0.09, 0.12]), fontproperties=font_, rotation=0, alpha=alpha, arrowprops=dict(arrowstyle="->", connectionstyle=connectionstyle, lw=lw))
        gca().annotate(r'Two component axisymmetric', xy=np.array([third_range[0], second_right[0]]), xytext=np.array([0.11, 0.17]), fontproperties=font_, rotation=0, alpha=alpha, arrowprops=dict(arrowstyle="->", connectionstyle=connectionstyle, lw=lw))
        gca().annotate(r'Two component plane strain', xy=np.array([0, 2.0/9.0]), xytext=np.array([0.13, 0.22]), fontproperties=font_, rotation=0, alpha=alpha, arrowprops=dict(arrowstyle="->", connectionstyle=connectionstyle, lw=lw))
        gca().annotate(r'Axisymmetric expansion', xy=np.array([third_range[4000], second_right[4000]]), xytext=np.array([0.15, 0.27]), fontproperties=font_, rotation=0, alpha=alpha, arrowprops=dict(arrowstyle="->", connectionstyle=connectionstyle, lw=lw))
        gca().annotate(r'Two component', xy=np.array([third_range[6000], second_upper[6000]]), xytext=np.array([0.05, 0.5]), fontproperties=font_, rotation=0, alpha=alpha, arrowprops=dict(arrowstyle="->", connectionstyle=connectionstyle, lw=lw))


        self.ax = gca()
        xlim(-0.05, 0.3)
        ylim(0.0, 0.7)
        grid(False)
        gca().axis('off')
        gcf().patch.set_visible(False)
        tight_layout()
开发者ID:anandpratap,项目名称:anisotropy_maps,代码行数:37,代码来源:maps.py

示例5: _get_3d_plot

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
    def _get_3d_plot(self, label_stable=True):
        """
        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 label_stable:
                if len(entry.composition.elements) == 1:
                    ax.text(coords[0], coords[1], coords[2], label)
                else:
                    ax.text(coords[0], coords[1], coords[2], str(count))
                    newlabels.append("{} : {}".format(count, latexify(label)))
                    count += 1
        plt.figtext(0.01, 0.01, "\n".join(newlabels))
        ax.axis("off")
        return plt
开发者ID:qimin,项目名称:pymatgen,代码行数:35,代码来源:plotter.py

示例6: show_linearComplexity

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
def show_linearComplexity(complexityVector, complexityType, seqlen, getFig=False):
    """
    The complexity plotting functions opperate outside of the general linear sequence
    framework as there are types of options/behaviours specific enough to the
    complexity plots that trying to shoe-horn them into the existing code would not
    be a good design decision.


    """

    n_bars = len(complexityVector[0,:])
    LW = __get_bar_edge_width(n_bars)
    
    # first generate the bar-plot and save the list of bars
    barlist = plt.bar(complexityVector[0,:], 
                      complexityVector[1,:],
                      width=1,
                      linewidth=LW,
                      edgecolor='k',
                      color='#A8A8A8')

    # set the limits
    plt.ylim([0,1])
    plt.xlim([1, seqlen])

    # set the font properties
    # set general font properties first
    font = {'family' : 'Bitstream Vera Sans',
            'weight' : 'normal',
            'size'   : 14}
    matplotlib.rc('font', **font)

    axes_pro = FontProperties()
    axes_pro.set_size('large')
    axes_pro.set_weight('bold')

    # set the axis labels
    plt.xlabel('Residue', fontproperties=axes_pro)
    plt.ylabel('Complexity', fontproperties=axes_pro)
    
    # set the title (i.e. what type of complexity was calculated)
    axes_pro.set_size('x-large')
    if complexityType == 'WF':
        title='Wooton-Federhen complexity'
    elif complexityType == 'LC':
        title='Linguistic complexity'
    elif complexityType == 'LZW':
        title='Lempel-Ziv-Welch complexity'
    else:
        raise PlottingException('Unexpected complexity type passed - should never happen')

    plt.title(title, fontproperties=axes_pro)
    
    # finally either show the plot or return the plt object
    if getFig:
        return plt
    else:
        plt.show()
开发者ID:Pappulab,项目名称:localCIDER,代码行数:60,代码来源:plotting.py

示例7: plot_basics

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
def plot_basics(data, data_inst, fig, units):
    '''
    This function is the main plotting function. Adapted from Newman's powerlaw package.
    '''
    import pylab
    pylab.rcParams['xtick.major.pad']='8'
    pylab.rcParams['ytick.major.pad']='8'
    pylab.rcParams['font.sans-serif']='Arial'

    from matplotlib import rc
    rc('font', family='sans-serif')
    rc('font', size=10.0)
    rc('text', usetex=False)

    from matplotlib.font_manager import FontProperties

    panel_label_font = FontProperties().copy()
    panel_label_font.set_weight("bold")
    panel_label_font.set_size(12.0)
    panel_label_font.set_family("sans-serif")

    n_data = 1
    n_graphs = 4
    from powerlaw import plot_pdf, Fit, pdf
    ax1 = fig.add_subplot(n_graphs,n_data,data_inst)
    x, y = pdf(data, linear_bins=True)
    ind = y>0
    y = y[ind]
    x = x[:-1]
    x = x[ind]
    ax1.scatter(x, y, color='r', s=.5, label='data')
    plot_pdf(data[data>0], ax=ax1, color='b', linewidth=2, label='PDF')
    from pylab import setp
    setp( ax1.get_xticklabels(), visible=False)
    plt.legend(loc = 'bestloc')

    ax2 = fig.add_subplot(n_graphs,n_data,n_data+data_inst, sharex=ax1)
    plot_pdf(data[data>0], ax=ax2, color='b', linewidth=2, label='PDF')
    fit = Fit(data, discrete=True)
    fit.power_law.plot_pdf(ax=ax2, linestyle=':', color='g',label='w/o xmin')
    p = fit.power_law.pdf()

    ax2.set_xlim(ax1.get_xlim())
    fit = Fit(data, discrete=True,xmin=3)
    fit.power_law.plot_pdf(ax=ax2, linestyle='--', color='g', label='w xmin')
    from pylab import setp
    setp(ax2.get_xticklabels(), visible=False)
    plt.legend(loc = 'bestloc')

    ax3 = fig.add_subplot(n_graphs,n_data,n_data*2+data_inst)#, sharex=ax1)#, sharey=ax2)
    fit.power_law.plot_pdf(ax=ax3, linestyle='--', color='g',label='powerlaw')
    fit.exponential.plot_pdf(ax=ax3, linestyle='--', color='r',label='exp')
    fit.plot_pdf(ax=ax3, color='b', linewidth=2)

    ax3.set_ylim(ax2.get_ylim())
    ax3.set_xlim(ax1.get_xlim())
    plt.legend(loc = 'bestloc')
    ax3.set_xlabel(units)
开发者ID:irisyupingren,项目名称:TSnet,代码行数:60,代码来源:textnetwork.py

示例8: finalize_DasPappu

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
def finalize_DasPappu(plt, legendOn, title, xLim, yLim):
    """
    Common function which finalizes up a plot by drawing on the regions 1-5, adding
    the legend and title. Used by both single and multiple phasePlot function

    """

    # define the five regions by filling the plot
    alphaval = 1
    reg1, = plt.fill([0, 0, 0.25], [0, 0.25, 0],
                     color='Chartreuse', alpha=alphaval, zorder=1)
    reg2, = plt.fill([0, 0, 0.35, 0.25], [0.25, 0.35, 0, 0],
                     color='MediumSeaGreen', alpha=alphaval, zorder=1)
    reg3, = plt.fill([0, 0.325, 0.675, 0.35], [0.35, 0.675,
                                               0.325, 0], color='DarkGreen', alpha=alphaval, zorder=1)

    reg4, = plt.fill([0, 0, 0.325], [0.35, 1, 0.675],
                     color='Red', alpha=alphaval, zorder=1)

    reg5, = plt.fill([0.35, 0.675, 1], [0, 0.325, 0],
                     color='Blue', alpha=alphaval, zorder=1)

    # set the plot limits
    plt.xlim([0, xLim])
    plt.ylim([0, yLim])

    # label the axes and set the title
    axes_pro = FontProperties()
    axes_pro.set_size('large')
    axes_pro.set_weight('bold')
    plt.xlabel(
        'Fraction of positively charged residues',
        fontproperties=axes_pro)
    plt.ylabel(
        'Fraction of negatively charged residues',
        fontproperties=axes_pro)

    # update the font property for the title
    axes_pro.set_size('x-large')
    plt.title(title, fontproperties=axes_pro)

    # if we the legend is on add the annotation
    if legendOn:

        # create and set set legend font options
        fontP = FontProperties()
        fontP.set_size('small')
        plt.legend([reg1, reg2, reg3, reg4, reg5],
                   ['Weak polyampholytes & polyelectrolytes:\nGlobules & tadpoles',
                    'Janus sequences:\nCollapsed or expanded - context dependent',
                    'Strong polyampholytes:\nCoils, hairpins, & chimeras',
                    'Negatively charged strong polyelectrolytes:\nSwollen coils',
                    'Positively charged strong polyelectrolytes:\nSwollen coils'],
                   prop=fontP)
    return plt
开发者ID:greatlse,项目名称:localCIDER,代码行数:57,代码来源:plotting.py

示例9: _show_2d_plot

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
    def _show_2d_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
        from matplotlib.font_manager import FontProperties
        (lines, labels, unstable) = self.pd_plot_data
        for x, y in lines:
            plt.plot(x, y, 'bo-', linewidth=3, markeredgecolor='b', markerfacecolor='r', markersize=10)
        font = FontProperties()
        font.set_weight('bold')
        font.set_size(20)
        count = 1

        if len(self._pd.elements) == 3:
            plt.axis('equal')
            plt.xlim((-0.1, 1.2))
            plt.ylim((-0.1, 1.0))
            plt.axis('off')
            legendstart = [1.0, 0.55]
        else:
            plt.xlim((-0.1, 1.4))
            legendstart = [1.1, 0.0]

        for coords in sorted(labels.keys()):
            entry = labels[coords]
            label = entry.name
            x = coords[0]
            if coords[0] >= math.sqrt(3) / 2:
                halign = 'left'
                x += 0.02
            else:
                halign = 'right'
                x += -0.02
            if coords[1] > 0:
                valign = 'bottom'
            else:
                valign = 'top'

            if len(entry.composition.elements) == 1:
                plt.text(x, coords[1], label, horizontalalignment=halign, verticalalignment=valign, fontproperties=font)
            else:
                plt.text(x, coords[1], str(count), horizontalalignment=halign, verticalalignment=valign, fontproperties=font)
                plt.text(legendstart[0], legendstart[1] - 0.05 * count, str(count) + " : " + label, horizontalalignment='left', verticalalignment='top', fontproperties=font)
                count += 1

        for entry, coords in unstable.items():
            label = entry.name
            plt.plot(coords[0], coords[1], 'bx', linewidth=3, markeredgecolor='b', markerfacecolor='b', markersize=10)

        F = plt.gcf()
        F.set_size_inches((8, 6.4))
        plt.show()
开发者ID:chenweis,项目名称:pymatgen,代码行数:57,代码来源:plotter.py

示例10: addtext

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
def addtext(ax, text = None, xloc = 1, yloc = -1.5, color = '#dd1c77', style =
'italic', weight = 'light', rotation = 10):
    font0 = FontProperties()
    font0.set_style(style)
    font0.set_weight(weight)
    if text == None:
        text = 'Happy 65 anniversary my beloved China  =^^=\n\
            Continue to give priority to development,\n\
            adhere to reform and innovation and \n\
            stay committed to the path of peaceful development\n\
                                                                       Love,R'
    ax.text(xloc, yloc, text , color = color, fontproperties=font0, rotation=rotation)
开发者ID:rikazry,项目名称:funplot,代码行数:14,代码来源:national_flag.py

示例11: watermark_seismic

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
def watermark_seismic(ax, text, size, colour, xn, yn=None):
    """
    Add semi-transparent text to the seismic.
    """
    font = FontProperties()
    font.set_weight('bold')
    font.set_family('sans-serif')
    style = {'size': size,
             'color': colour,
             'alpha': 0.5,
             'fontproperties': font
             }
    alignment = {'rotation': 33,
                 'horizontalalignment': 'left',
                 'verticalalignment': 'baseline'
                 }
    params = dict(style, **alignment)

    # Axis ranges.
    xr = ax.get_xticks()
    yr = ax.get_yticks()
    aspect = xr.size / yr.size
    yn = yn or (xn / aspect)
    yn += 1

    # Positions for even lines.
    xpos = np.linspace(xr[0], xr[-1], xn)[:-1]
    ypos = np.linspace(yr[0], yr[-1], yn)[:-1]

    # Intervals.
    xiv = xpos[1] - xpos[0]
    yiv = ypos[1] - ypos[0]

    # Adjust the y positions.
    ypos += yiv / 2

    # Place everything.
    c = False
    for y in ypos:
        for x in xpos:
            if c:
                xi = x + xiv / 2
            else:
                xi = x
            ax.text(xi, y, text, clip_box=ax.clipbox, clip_on=True, **params)
        c = not c

    return ax
开发者ID:svanschalkwyk,项目名称:seisplot,代码行数:50,代码来源:seisplot.py

示例12: finalize_uversky

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
def finalize_uversky(plt, legendOn, title, xLim, yLim):
    """
    Common function which finalizes up a plot by drawing on the regions 1-5, adding
    the legend and title. Used by both single and multiple phasePlot function

    """

    # define the five regions by filling the plot
    alphaval = 0.15

    # folded region
    reg1, = plt.fill([0.0, 0, 0.772], [1, 0.413, 1],
                     color='Chartreuse', alpha=0.25, zorder=1)

    # unfolded region
    reg2, = plt.fill([0, 0, 0.772, 1, 1],
                     [0, 0.413, 1, 1, 0],
                     color='Red',
                     alpha=0.15,
                     zorder=1)

    # set the plot limits
    plt.xlim([0, xLim])
    plt.ylim([0, yLim])

    # label the axes and set the title
    axes_pro = FontProperties()
    axes_pro.set_size('large')
    axes_pro.set_weight('bold')
    plt.xlabel('Mean net charge', fontproperties=axes_pro)
    plt.ylabel('Mean hydropathy <H>', fontproperties=axes_pro)

    # update the font property for the title
    axes_pro.set_size('x-large')
    plt.title(title, fontproperties=axes_pro)

    # if we the legend is on add the annotation
    if legendOn:

        # create and set set legend font options
        fontP = FontProperties()
        fontP.set_size('small')
        plt.legend([reg1, reg2], ['Folded proteins',
                                  'Natively unfolded'], prop=fontP)

    return plt
开发者ID:greatlse,项目名称:localCIDER,代码行数:48,代码来源:plotting.py

示例13: _get_plot

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]
    def _get_plot(self, label_stable=True, label_unstable=False):
        """
        Plot convex hull of Pourbaix Diagram entries
        """
        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(14)
        (lines, labels, unstable) = self.pourbaix_hull_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 = self.print_name(entry)
            if label_stable:
                ax.text(coords[0], coords[1], coords[2], str(count))
                newlabels.append("{} : {}".format(
                    count, latexify_ion(latexify(label))))
                count += 1

        if self.show_unstable:
            for entry in unstable.keys():
                label = self.print_name(entry)
                coords = unstable[entry]
                ax.plot([coords[0], coords[0]], [coords[1], coords[1]],
                        [coords[2], coords[2]], "bo", markerfacecolor="g",
                        markersize=10)
                ax.text(coords[0], coords[1], coords[2], str(count))
                newlabels.append("{} : {}".format(
                    count, latexify_ion(latexify(label))))
                count += 1

        plt.figtext(0.01, 0.01, "\n".join(newlabels))
        plt.xlabel("pH")
        plt.ylabel("V")
#        plt.tight_layout()
        return plt
开发者ID:akashneo,项目名称:pymatgen,代码行数:46,代码来源:plotter.py

示例14: _draw_tracks

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]

#.........这里部分代码省略.........
                    Y_major_ticks = track.yticks_major
                    if (track.yticklabels_major != None) \
                       and len(track.yticklabels_major) == len(track.yticks_major):
                        Y_major_ticks_labels = track.yticklabels_major
                else:
                    Y_major_ticks = None
                if ('left' in track.draw_axis) and track.yticks_major:
                    axis.set_yticks(Y_major_ticks)
                '''major ticks labels '''
                if Y_major_ticks and track.show_yticklabels:
                    if Y_major_ticks_labels == None:
                        Y_major_ticks_labels = []
                        for i in Y_major_ticks:
                            Y_major_ticks_labels.append(i)
                    axis.set_yticklabels(Y_major_ticks_labels, fontsize=track.tickfontsize)
                else:
                    axis.yaxis.set_tick_params(labelsize=track.tickfontsize)
                '''minor Y ticks '''
                Y_minor_ticks_labels = None
                if track.yticks_minor is not None:
                    Y_minor_ticks = track.yticks_minor
                    if (track.yticklabels_minor is not None) \
                       and len(track.yticklabels_minor) == len(track.yticks_minor):
                        Y_minor_ticks_labels = track.yticklabels_minor
                else:
                    Y_minor_ticks = None
                if ('left' in track.draw_axis) and track.yticks_minor:
                    axis.set_yticks(Y_minor_ticks, minor=True)
                '''minor ticks labels '''
                if Y_minor_ticks and track.show_yticklabels:
                    if Y_minor_ticks_labels is None:
                        Y_minor_ticks_labels = []
                        for i in Y_minor_ticks:
                            if i in Y_major_ticks:
                                Y_minor_ticks_labels.append('')
                            else:
                                Y_minor_ticks_labels.append(i)
                    axis.set_yticklabels(Y_minor_ticks_labels, fontsize=track.tickfontsize_minor, minor=True)
                else:
                    axis.yaxis.set_tick_params(which='minor', labelsize=track.tickfontsize)
                    
                       
                    

                '''draw grid'''
                if self.grid:
                    if (self.grid == 'major') or (self.grid == 'both'):
                        for X in auto_X_major_ticks:
                            axis.axvline(X,ls=':',c='grey',alpha=0.66, zorder = -1)
                    if (self.grid == 'minor') or (self.grid == 'both'):
                        for X in auto_X_minor_ticks:
                            axis.axvline(X,ls=':',c='grey',alpha=0.33, zorder = -1)
                
                
                '''add feature patches to track axes '''
                for feature in track.features:
                    self.Drawn_objects.append(feature)
                    for patch in feature.patches:
                        if isinstance(patch, matplotlib.lines.Line2D):
                            axis.add_line(patch)
                        elif isinstance(patch, matplotlib.patches.Patch):
                            axis.add_patch(patch)
                        else:
                            axis.add_artist(patch)
                        patch.set_transform(axis.transData)# IMPORTANT WORKAROUND!!! if not manually set, transform is not passed correctly in Line2D objects
                                        
                    feature.draw_feat_name(ax=axis)
                    for feat_name in feature.feat_name:
                        #feat_name.set_visible(True)
                        axis.add_artist(feat_name)

                if track.draw_cb:
                    cb_axis = matplotlib.pyplot.axes([axis_left_pad + axis_width + cbar_axis_space - cbar_right_pad ,axis_bottom_pad, cbar_extent, axis_height ],) 
                    if (track.min_score == None) and (track.max_score == None):
                        for feat in track.features:
                            if feat.norm != None:
                                track.norm = feat.norm
                                break

                    cb1 = matplotlib.colorbar.ColorbarBase(cb_axis, cmap=track.cm,
                                                           norm=track.norm,
                                                           alpha = track.cb_alpha,
                                                           orientation='vertical')
                    if track.cb_label:
                        cb1.set_label(track.cb_label)
                    #cb_axis.axes.set_axis_off()
                    for label in cb_axis.get_yticklabels():
                        label.set_fontsize('xx-small')
                        
                '''handle legend '''
                legend_font=FontProperties()
                legend_font.set_size('x-small')
                legend_font.set_family('serif')
                legend_font.set_weight('normal')
                axis.legend(prop = legend_font)
        
        if not self.use_existing_figure:
            '''set panel size and panning '''
            self.fig.set_figheight(self.fig_height)
            self.fig.set_figwidth(self.fig_width)
开发者ID:webermarcolivier,项目名称:BioGraPy,代码行数:104,代码来源:drawer.py

示例15: TickLabels

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_weight [as 别名]

#.........这里部分代码省略.........
        self._ax2.xaxis.apl_labels_style = style
        self._ax2.yaxis.apl_labels_style = style

    @auto_refresh
    @fixdocstring
    def set_font(
        self, family=None, style=None, variant=None, stretch=None, weight=None, size=None, fontproperties=None
    ):
        """
        Set the font of the tick labels

        Optional Keyword Arguments:

        common: family, style, variant, stretch, weight, size, fontproperties

        Default values are set by matplotlib or previously set values if
        set_font has already been called. Global default values can be set by
        editing the matplotlibrc file.
        """

        if family:
            self._label_fontproperties.set_family(family)

        if style:
            self._label_fontproperties.set_style(style)

        if variant:
            self._label_fontproperties.set_variant(variant)

        if stretch:
            self._label_fontproperties.set_stretch(stretch)

        if weight:
            self._label_fontproperties.set_weight(weight)

        if size:
            self._label_fontproperties.set_size(size)

        if fontproperties:
            self._label_fontproperties = fontproperties

        for tick in self._ax1.get_xticklabels():
            tick.set_fontproperties(self._label_fontproperties)
        for tick in self._ax1.get_yticklabels():
            tick.set_fontproperties(self._label_fontproperties)
        for tick in self._ax2.get_xticklabels():
            tick.set_fontproperties(self._label_fontproperties)
        for tick in self._ax2.get_yticklabels():
            tick.set_fontproperties(self._label_fontproperties)

    @auto_refresh
    def show(self):
        """
        Show the x- and y-axis tick labels
        """
        self.show_x()
        self.show_y()

    @auto_refresh
    def hide(self):
        """
        Hide the x- and y-axis tick labels
        """
        self.hide_x()
        self.hide_y()
开发者ID:wkerzendorf,项目名称:aplpy,代码行数:69,代码来源:labels.py


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