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


Python FontProperties.set_style方法代码示例

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


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

示例1: plot_triangle

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [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

示例2: format_plot

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [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: addtext

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [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

示例4: Colorbar

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

#.........这里部分代码省略.........
        self.set_font(fontproperties=self._label_fontproperties)

    @auto_refresh
    def set_ticks(self, ticks):
        '''
        Set the position of the ticks on the colorbar.
        '''
        self._base_settings['ticks'] = ticks
        self.show(**self._base_settings)
        self.set_font(fontproperties=self._label_fontproperties)

    @auto_refresh
    def set_labels(self, labels):
        '''
        Set whether to show numerical labels.
        '''
        self._base_settings['labels'] = labels
        self.show(**self._base_settings)
        self.set_font(fontproperties=self._label_fontproperties)

    @auto_refresh
    def set_box(self, box, box_orientation='vertical'):
        '''
        Set the box within which to place the colorbar. This should be in the
        form [xmin, ymin, dx, dy] and be in relative figure units. The
        orientation of the colorbar within the box can be controlled with the
        box_orientation argument.
        '''
        self._base_settings['box'] = box
        self._base_settings['box_orientation'] = box_orientation
        self.show(**self._base_settings)
        self.set_font(fontproperties=self._label_fontproperties)

    # FONT PROPERTIES

    @auto_refresh
    def set_label_properties(self, *args, **kwargs):
        warnings.warn("set_label_properties is deprecated - use set_font instead", DeprecationWarning)
        self.set_font(*args, **kwargs)

    @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 label in self._colorbar_axes.get_xticklabels():
            label.set_fontproperties(self._label_fontproperties)
        for label in self._colorbar_axes.get_yticklabels():
            label.set_fontproperties(self._label_fontproperties)

    # FRAME PROPERTIES

    @auto_refresh
    def set_frame_linewidth(self, linewidth):
        '''
        Set the linewidth of the colorbar frame, in points
        '''
        warnings.warn("This method is not functional at this time")
        for key in self._colorbar_axes.spines:
            self._colorbar_axes.spines[key].set_linewidth(linewidth)

    @auto_refresh
    def set_frame_color(self, color):
        '''
        Set the color of the colorbar frame, in points
        '''
        warnings.warn("This method is not functional at this time")
        for key in self._colorbar_axes.spines:
            self._colorbar_axes.spines[key].set_edgecolor(color)
开发者ID:d80b2t,项目名称:python,代码行数:104,代码来源:colorbar.py

示例5: AxisLabels

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [as 别名]
class AxisLabels(object):

    def __init__(self, parent):

        # Store references to axes
        self._ax1 = parent._ax1
        self._ax2 = parent._ax2
        self._wcs = parent._wcs
        self._figure = parent._figure

        # Set font
        self._label_fontproperties = FontProperties()

        self._ax2.yaxis.set_label_position('right')
        self._ax2.xaxis.set_label_position('top')

        system, equinox, units = wcs_util.system(self._wcs)

        if system == 'equatorial':
            if equinox == 'b1950':
                self.set_xtext('RA (B1950)')
                self.set_ytext('Dec (B1950)')
            else:
                self.set_xtext('RA (J2000)')
                self.set_ytext('Dec (J2000)')
        elif system == 'galactic':
            self.set_xtext('Galactic Longitude')
            self.set_ytext('Galactic Latitude')
        else:
            self.set_xtext('Ecliptic Longitude')
            self.set_ytext('Ecliptic Latitude')

        self.set_xposition('bottom')
        self.set_yposition('left')

    @auto_refresh
    def set_xtext(self, label):
        """
        Set the x-axis label text
        """
        self._xlabel1 = self._ax1.set_xlabel(label)
        self._xlabel2 = self._ax2.set_xlabel(label)

    @auto_refresh
    def set_ytext(self, label):
        """
        Set the y-axis label text
        """
        self._ylabel1 = self._ax1.set_ylabel(label)
        self._ylabel2 = self._ax2.set_ylabel(label)

    @auto_refresh
    def set_xpad(self, pad):
        """
        Set the x-axis label displacement, in points
        """
        self._xlabel1 = self._ax1.set_xlabel(self._xlabel1.get_text(), labelpad=pad)
        self._xlabel2 = self._ax2.set_xlabel(self._xlabel2.get_text(), labelpad=pad)

    @auto_refresh
    def set_ypad(self, pad):
        """
        Set the y-axis label displacement, in points
        """
        self._ylabel1 = self._ax1.set_ylabel(self._ylabel1.get_text(), labelpad=pad)
        self._ylabel2 = self._ax2.set_ylabel(self._ylabel2.get_text(), labelpad=pad)

    @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 axis 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)

#.........这里部分代码省略.........
开发者ID:cdeil,项目名称:aplpy,代码行数:103,代码来源:axis_labels.py

示例6: TickLabels

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [as 别名]
class TickLabels(object):
    def __init__(self, parent):

        # Store references to axes
        self._ax1 = parent._ax1
        self._ax2 = parent._ax2
        self._wcs = parent._wcs
        self._figure = parent._figure

        # Save plotting parameters (required for @auto_refresh)
        self._parameters = parent._parameters

        # Set font
        self._label_fontproperties = FontProperties()

        self.set_style("plain")

        system, equinox, units = wcs_util.system(self._wcs)

        # Set default label format
        if self._wcs.xaxis_coord_type in ["longitude", "latitude"]:
            if system["name"] == "equatorial":
                if self._wcs.xaxis_coord_type == "longitude":
                    self.set_xformat("hh:mm:ss.ss")
                else:
                    self.set_xformat("dd:mm:ss.s")
            else:
                self.set_xformat("ddd.dddd")
        else:
            self.set_xformat("%g")

        if self._wcs.yaxis_coord_type in ["longitude", "latitude"]:
            if system["name"] == "equatorial":
                if self._wcs.yaxis_coord_type == "longitude":
                    self.set_yformat("hh:mm:ss.ss")
                else:
                    self.set_yformat("dd:mm:ss.s")
            else:
                self.set_yformat("ddd.dddd")
        else:
            self.set_yformat("%g")

        # Set major tick formatters
        fx1 = WCSFormatter(wcs=self._wcs, coord="x")
        fy1 = WCSFormatter(wcs=self._wcs, coord="y")
        self._ax1.xaxis.set_major_formatter(fx1)
        self._ax1.yaxis.set_major_formatter(fy1)

        fx2 = mpl.NullFormatter()
        fy2 = mpl.NullFormatter()
        self._ax2.xaxis.set_major_formatter(fx2)
        self._ax2.yaxis.set_major_formatter(fy2)

        # Cursor display
        self._ax1._cursor_world = True
        self._figure.canvas.mpl_connect("key_press_event", self._set_cursor_prefs)

    @auto_refresh
    def set_xformat(self, format):
        """
        Set the format of the x-axis tick labels. If the x-axis type is
        ``longitude`` or ``latitude``, then the options are:

            * ``ddd.ddddd`` - decimal degrees, where the number of decimal places can be varied
            * ``hh`` or ``dd`` - hours (or degrees)
            * ``hh:mm`` or ``dd:mm`` - hours and minutes (or degrees and arcminutes)
            * ``hh:mm:ss`` or ``dd:mm:ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds)
            * ``hh:mm:ss.ss`` or ``dd:mm:ss.ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds), where the number of decimal places can be varied.

        If the x-axis type is ``scalar``, then the format should be a valid
        python string format beginning with a ``%``.

        If one of these arguments is not specified, the format for that axis
        is left unchanged.
        """
        if self._wcs.xaxis_coord_type in ["longitude", "latitude"]:
            if format.startswith("%"):
                raise Exception("Cannot specify Python format for longitude or latitude")
            try:
                if not self._ax1.xaxis.apl_auto_tick_spacing:
                    au._check_format_spacing_consistency(format, self._ax1.xaxis.apl_tick_spacing)
            except au.InconsistentSpacing:
                warnings.warn(
                    "WARNING: Requested label format is not accurate enough to display ticks. The label format will not be changed."
                )
                return
        else:
            if not format.startswith("%"):
                raise Exception("For scalar tick labels, format should be a Python format beginning with %")

        self._ax1.xaxis.apl_label_form = format
        self._ax2.xaxis.apl_label_form = format

    @auto_refresh
    def set_yformat(self, format):
        """
        Set the format of the y-axis tick labels. If the y-axis type is
        ``longitude`` or ``latitude``, then the options are:

            * ``ddd.ddddd`` - decimal degrees, where the number of decimal places can be varied
#.........这里部分代码省略.........
开发者ID:wkerzendorf,项目名称:aplpy,代码行数:103,代码来源:labels.py

示例7: plot_trial_steps

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [as 别名]
    def plot_trial_steps(self):
        '''Plot target (sig-eps-curve of the tensile test) and trial curves
        and corresponding phi function together with trail steps from the iteration process.
        NOTE: the global variable 'rec_trial_steps' must be set to 'True' in order to store the iteration values
              within the global variables 'phi_trial_list_n' and 'sig_trial_list_n'
        n - index of the time steps to be considered
        i - index of the iteration steps performed in order to fit the target curve
        '''
        #-------------------------------------------------------------------
        # configure the style of the font to be used for labels and ticks
        #-------------------------------------------------------------------
        #
        from matplotlib.font_manager import FontProperties
        font = FontProperties()
#        font.serif         : Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman
#        font.sans-serif    : Helvetica, Avant Garde, Computer Modern Sans serif
#        font.cursive       : Zapf Chancery
#        font.monospace     : Courier, Computer Modern Typewriter
        font.set_name('Script MT')
        # name = ['Times New Roman', 'Helvetica', 'Script MT'] #?
        font.set_family('serif')
        # family = ['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace']
        font.set_style('normal')
        # style  = ['normal', 'italic', 'oblique']
        font.set_size('small')
        # size  = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', '11']
        font.set_variant('normal')
        # variant= ['normal', 'small-caps']
        font.set_weight('medium')
        # weight = ['light', 'normal', 'medium', 'semibold', 'bold', 'heavy', 'black']

        #-------------------------------------------------------------------

        p.figure(facecolor='white', dpi=600,
                 figsize=(8, 6))  # white background

        # time list corresponding to the specified numbers of steps and step size
        #
        step_list = [n * self.step_size for n in range(self.n_steps + 1)]

        # get list of lists containing the trial values of 'sig_app' and 'phi_trail'
        # the lists are defined as global variables of 'MATSCalibDamageFn' and are filled
        # within the iteration process when the method 'get_lack_of_fit" is called
        #
        phi_trial_list_n = [[1.]] + self.phi_trial_list_n
        sig_trial_list_n = [[0.]] + self.sig_trial_list_n

        xrange = 10.  # plotting range for strain [mm/m]
        yrange = 15.  # plotting range for stress [MPa]

        for n in range(self.n_steps):
            for i in range(len(phi_trial_list_n[n + 1])):
                x = np.array([step_list[n], step_list[n + 1]])
                eps = 1000. * x  # plot strains in permil on the x-axis
                #--------------------------------------
                # sig-eps trial
                #--------------------------------------
                # plot the numerically calculated sig-eps-curve (tensile test)
                # (with trial steps)
                #
                sig_trail = np.array(
                    [sig_trial_list_n[n][-1], sig_trial_list_n[n + 1][i]])
                p.subplot(222)
                p.plot(eps, sig_trail, color='k', linewidth=1)
                p.xlabel(r'strain $\varepsilon$ [1E-3]', fontproperties=font)
                p.ylabel('stress $\sigma$ [MPa]', fontproperties=font)
                if self.format_ticks:
                    # format ticks for plot
                    p.axis([0, xrange, 0., yrange], fontproperties=font)
                    locs, labels = p.xticks()
                    p.xticks(locs, map(lambda x: "%.0f" %
                                       x, locs), fontproperties=font)
                    locs, labels = p.yticks()
                    p.yticks(locs, map(lambda x: "%.0f" %
                                       x, locs), fontproperties=font)

                #--------------------------------------
                # phi_trail
                #--------------------------------------
                # plot the fitted phi-function
                # (with trial steps)
                #
                p.subplot(224)
                phi_trail = np.array(
                    [phi_trial_list_n[n][-1], phi_trial_list_n[n + 1][i]])
                p.plot(eps, phi_trail, color='k', linewidth=1)
                p.xlabel(r'strain $\varepsilon$ [1E-3]', fontproperties=font)
                p.ylabel('integrity $\phi$ [-]', fontproperties=font)
                if self.format_ticks:
                    # format ticks for plot
                    p.yticks([0, 0.2, 0.4, 0.6, 0.8, 1.0])
                    p.axis([0, xrange, 0., 1.])
                    locs, labels = p.xticks()
                    p.xticks(locs, map(lambda x: "%.0f" %
                                       x, locs), fontproperties=font)
                    locs, labels = p.yticks()
                    p.yticks(locs, map(lambda x: "%.1f" %
                                       x, locs), fontproperties=font)

        #--------------------------------------
#.........这里部分代码省略.........
开发者ID:simvisage,项目名称:simvisage,代码行数:103,代码来源:mats_calib_damage_fn.py

示例8: Colorbar

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

#.........这里部分代码省略.........
        self.set_axis_label_font(fontproperties=self._axislabel_fontproperties)

    # FONT PROPERTIES

    # @auto_refresh
    def set_label_properties(self, *args, **kwargs):
        warnings.warn("set_label_properties is deprecated - use set_font instead", DeprecationWarning)
        self.set_font(*args, **kwargs)

    # @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.

        Parameters
        ----------

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

        Notes
        -----

        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._ticklabel_fontproperties.set_family(family)

        if style:
            self._ticklabel_fontproperties.set_style(style)

        if variant:
            self._ticklabel_fontproperties.set_variant(variant)

        if stretch:
            self._ticklabel_fontproperties.set_stretch(stretch)

        if weight:
            self._ticklabel_fontproperties.set_weight(weight)

        if size:
            self._ticklabel_fontproperties.set_size(size)

        if fontproperties:
            self._ticklabel_fontproperties = fontproperties

        # Update the tick label font properties
        for label in self._colorbar_axes.get_xticklabels():
            label.set_fontproperties(self._ticklabel_fontproperties)
        for label in self._colorbar_axes.get_yticklabels():
            label.set_fontproperties(self._ticklabel_fontproperties)

        # Also update the offset text font properties
        label = self._colorbar_axes.xaxis.get_offset_text()
        label.set_fontproperties(self._ticklabel_fontproperties)
        label = self._colorbar_axes.yaxis.get_offset_text()
        label.set_fontproperties(self._ticklabel_fontproperties)

    # @auto_refresh
    # @fixdocstring
    def set_axis_label_font(self, family=None, style=None, variant=None,
                            stretch=None, weight=None, size=None,
开发者ID:anizami,项目名称:aplpy_wrapper,代码行数:70,代码来源:colorbar.py

示例9: SimDB

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [as 别名]
from matresdev.db.simdb import \
    SimDB

from matresdev.db.simdb.simdb_class import \
    SimDBClass, SimDBClassExt

simdb = SimDB()

from pickle import dump, load

from matplotlib.font_manager import FontProperties
font = FontProperties()
font.set_name('Script MT')
font.set_family('serif')
font.set_style('normal')
font.set_size('large')
font.set_variant('normal')
font.set_weight('medium')

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')
开发者ID:sarosh-quraishi,项目名称:simvisage,代码行数:32,代码来源:show_results.py

示例10: FontProperties

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [as 别名]
                      horizontalalignment='left')
ax.set_ylabel('Damped oscillation [V]')

plt.show()

##############################################################################
# All the labelling in this tutorial can be changed by manipulating the
# `matplotlib.font_manager.FontProperties` method, or by named kwargs to
# `~matplotlib.axes.Axes.set_xlabel`

from matplotlib.font_manager import FontProperties

font = FontProperties()
font.set_family('serif')
font.set_name('Times New Roman')
font.set_style('italic')

fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.15, left=0.2)
ax.plot(x1, y1)
ax.set_xlabel('time [s]', fontsize='large', fontweight='bold')
ax.set_ylabel('Damped oscillation [V]', fontproperties=font)

plt.show()

##############################################################################
# Finally, we can use native TeX rendering in all text objects and have
# multiple lines:

fig, ax = plt.subplots(figsize=(5, 3))
fig.subplots_adjust(bottom=0.2, left=0.2)
开发者ID:dopplershift,项目名称:matplotlib,代码行数:33,代码来源:text_intro.py

示例11: render_barchart

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

#.........这里部分代码省略.........

    if not table_height == num_cats:
        raise ValueError('The number of provided categories differ.')
    elif not table_width == num_samples:
        raise ValueError('The number of samples differ.')

    # Sets up the colormap
    num_colors = len(colors[:, 0])
    if num_colors is None:
        colormap = ones((table_height, 3))
    elif not isinstance(colors, ndarray):
        raise TypeError('The colormap must be a numpy array.')
    elif num_colors == 1:
        colormap = colors*ones((table_height, 1))
    elif num_colors >= table_height:
        colormap = colors
    else:
        raise ValueError('The color map cannot be determined. \nColors must '
                         'be a a list of n x 3 lists where n is the number of '
                         'patches being supplied or a single color to be used'
                         ' for all patches.')

    # Sets up the edge colormap
    if show_edge:
        edgecolor = zeros((num_cats, 3))
    else:
        edgecolor = colormap

    # Sets up the font properties for each of the label objects
    if label_font is None:
        label_font = FontProperties()
        label_font.set_size(20)
        label_font.set_family('sans-serif')
        label_font.set_style('italic')

    if legend_font is None:
        legend_font = FontProperties()
        legend_font.set_size(15)
        legend_font.set_family('sans-serif')

    if tick_font is None:
        tick_font = FontProperties()
        tick_font.set_size(15)
        tick_font.set_family('sans-serif')

    if title_font is None:
        title_font = FontProperties()
        title_font.set_size(30)
        title_font.set_family('sans-serif')

    # Sets up LateX rendering if desired
    if use_latex:
        rc('text', usetex=True)
        rc('font', **{'family': rc_fam, rc_fam: rc_font})

    # Sets up the x ticks.
    # Bar width is divided by two because the tick is assumed to be at the
    # center of the bar.
    x_tick = arange(num_samples*x_tick_interval)
    x_max = x_min + num_samples*x_tick_interval
    bar_left = x_tick - bar_width/2

    # Creates the x tick labels.
    if x_axis:
        x_text_labels = map(str, sample_names)
    else:
开发者ID:ETaSky,项目名称:American-Gut,代码行数:70,代码来源:make_phyla_plots.py

示例12: AxisLabels

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

#.........这里部分代码省略.........
        """
        Set the x-axis label displacement, in points
        """
        self._xlabel1 = self._ax1.set_xlabel(self._xlabel1.get_text(), labelpad=pad)
        self._xlabel2 = self._ax2.set_xlabel(self._xlabel2.get_text(), labelpad=pad)

    @auto_refresh
    def set_ypad(self, pad):
        """
        Set the y-axis label displacement, in points
        """
        self._ylabel1 = self._ax1.set_ylabel(self._ylabel1.get_text(), labelpad=pad)
        self._ylabel2 = self._ax2.set_ylabel(self._ylabel2.get_text(), labelpad=pad)

    @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 axis 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

        self._xlabel1.set_fontproperties(self._label_fontproperties)
        self._xlabel2.set_fontproperties(self._label_fontproperties)
        self._ylabel1.set_fontproperties(self._label_fontproperties)
        self._ylabel2.set_fontproperties(self._label_fontproperties)

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

    @auto_refresh
    def hide(self):
        """
开发者ID:d80b2t,项目名称:python,代码行数:70,代码来源:axis_labels.py

示例13: TickLabels

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [as 别名]
class TickLabels(object):

    def __init__(self, parent):

        # Store references to axes
        self._ax1 = parent._ax1
        self._ax2 = parent._ax2
        self._wcs = parent._wcs
        self._figure = parent._figure

        # Set font
        self._label_fontproperties = FontProperties()

        self.set_style('plain')

        system, equinox, units = wcs_util.system(self._wcs)

        # Set default label format
        if system == 'equatorial':
            self.set_xformat("hh:mm:ss.ss")
            self.set_yformat("dd:mm:ss.s")
        else:
            self.set_xformat("ddd.dddd")
            self.set_yformat("dd.dddd")

        # Set major tick formatters
        fx1 = WCSFormatter(wcs=self._wcs, coord='x')
        fy1 = WCSFormatter(wcs=self._wcs, coord='y')
        self._ax1.xaxis.set_major_formatter(fx1)
        self._ax1.yaxis.set_major_formatter(fy1)

        fx2 = mpl.NullFormatter()
        fy2 = mpl.NullFormatter()
        self._ax2.xaxis.set_major_formatter(fx2)
        self._ax2.yaxis.set_major_formatter(fy2)

    @auto_refresh
    def set_xformat(self, format):
        '''
        Set the format of the x-axis tick labels:

            * ``ddd.ddddd`` - decimal degrees, where the number of decimal places can be varied
            * ``hh`` or ``dd`` - hours (or degrees)
            * ``hh:mm`` or ``dd:mm`` - hours and minutes (or degrees and arcminutes)
            * ``hh:mm:ss`` or ``dd:mm:ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds)
            * ``hh:mm:ss.ss`` or ``dd:mm:ss.ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds), where the number of decimal places can be varied.

        If one of these arguments is not specified, the format for that axis is left unchanged.
        '''
        try:
            if not self._ax1.xaxis.apl_auto_tick_spacing:
                au._check_format_spacing_consistency(format, self._ax1.xaxis.apl_tick_spacing)
        except au.InconsistentSpacing:
            warnings.warn("WARNING: Requested label format is not accurate enough to display ticks. The label format will not be changed.")
            return

        self._ax1.xaxis.apl_label_form = format
        self._ax2.xaxis.apl_label_form = format

    @auto_refresh
    def set_yformat(self, format):
        '''
        Set the format of the y-axis tick labels:

            * ``ddd.ddddd`` - decimal degrees, where the number of decimal places can be varied
            * ``hh`` or ``dd`` - hours (or degrees)
            * ``hh:mm`` or ``dd:mm`` - hours and minutes (or degrees and arcminutes)
            * ``hh:mm:ss`` or ``dd:mm:ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds)
            * ``hh:mm:ss.ss`` or ``dd:mm:ss.ss`` - hours, minutes, and seconds (or degrees, arcminutes, and arcseconds), where the number of decimal places can be varied.

        If one of these arguments is not specified, the format for that axis is left unchanged.
        '''
        try:
            if not self._ax1.yaxis.apl_auto_tick_spacing:
                au._check_format_spacing_consistency(format, self._ax1.yaxis.apl_tick_spacing)
        except au.InconsistentSpacing:
            warnings.warn("WARNING: Requested label format is not accurate enough to display ticks. The label format will not be changed.")
            return

        self._ax1.yaxis.apl_label_form = format
        self._ax2.yaxis.apl_label_form = format

    @auto_refresh
    def set_style(self, style):
        """
        Set the format of the x-axis tick labels. This can be 'colons' or 'plain':

            * 'colons' uses colons as separators, for example 31:41:59.26 +27:18:28.1
            * 'plain' uses letters and symbols as separators, for example 31h41m59.26s +27º18'28.1"
        """

        if style is 'latex':
            warnings.warn("latex has now been merged with plain - whether or not to use LaTeX is controled through set_system_latex")
            style = 'plain'

        if not style in ['colons', 'plain']:
            raise Exception("Label style should be one of colons/plain")

        self._ax1.xaxis.apl_labels_style = style
        self._ax1.yaxis.apl_labels_style = style
#.........这里部分代码省略.........
开发者ID:hamogu,项目名称:aplpy,代码行数:103,代码来源:labels.py

示例14: FontProperties

# 需要导入模块: from matplotlib.font_manager import FontProperties [as 别名]
# 或者: from matplotlib.font_manager.FontProperties import set_style [as 别名]
import os
import random
import matplotlib
matplotlib.use('Agg')

import datetime
import pylab as P
import numpy as N

import orbit_plot_utils
from variables import data_dict
from variables import color_table

from matplotlib.font_manager import FontProperties
ital = FontProperties()
ital.set_style('italic')

au2km = 149597870.691
xpagescale = au2km*0.25
ypagescale = xpagescale/8.5*11.0
ymin = -ypagescale*1.75/11.0
ymax = ymin + ypagescale

pages = range(198)
xoffset = -xpagescale*4.75/8.5

# 72 (points/inch) * 8.5 (inches) / xpagescale (km)
km2points = 72*8.5/xpagescale
points2km = 1.0/km2points

planets = [i for i in data_dict if str(i)[-2:] == '99' and i > 0 and i < 1000]
开发者ID:FHFard,项目名称:scipy2013_talks,代码行数:33,代码来源:02_create_plots.py


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