當前位置: 首頁>>代碼示例>>Python>>正文


Python matplotlib.cbook方法代碼示例

本文整理匯總了Python中matplotlib.cbook方法的典型用法代碼示例。如果您正苦於以下問題:Python matplotlib.cbook方法的具體用法?Python matplotlib.cbook怎麽用?Python matplotlib.cbook使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib的用法示例。


在下文中一共展示了matplotlib.cbook方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: OSXInstalledFonts

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def OSXInstalledFonts(directories=None, fontext='ttf'):
    """
    Get list of font files on OS X - ignores font suffix by default.
    """
    if directories is None:
        directories = OSXFontDirectories

    fontext = get_fontext_synonyms(fontext)

    files = []
    for path in directories:
        if fontext is None:
            files.extend(cbook.listFiles(path, '*'))
        else:
            files.extend(list_fonts(path, fontext))
    return files 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:font_manager.py

示例2: _print_image

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def _print_image(self, filename, format, *args, **kwargs):
        width, height = self.get_width_height()
        pixmap = gtk.gdk.Pixmap (None, width, height, depth=24)
        self._render_figure(pixmap, width, height)

        # jpg colors don't match the display very well, png colors match
        # better
        pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8,
                                width, height)
        pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
                                 0, 0, 0, 0, width, height)

        # set the default quality, if we are writing a JPEG.
        # http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#method-gdkpixbuf--save
        options = cbook.restrict_dict(kwargs, ['quality'])
        if format in ['jpg','jpeg']:
           if 'quality' not in options:
              options['quality'] = rcParams['savefig.jpeg_quality']
           options['quality'] = str(options['quality'])
            
        pixbuf.save(filename, format, options=options) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:23,代碼來源:backend_gdk.py

示例3: is_frame_like

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def is_frame_like(self):
        """return True if directly on axes frame

        This is useful for determining if a spine is the edge of an
        old style MPL plot. If so, this function will return True.
        """
        self._ensure_position_is_set()
        position = self._position
        if cbook.is_string_like(position):
            if position == 'center':
                position = ('axes', 0.5)
            elif position == 'zero':
                position = ('data', 0)
        assert len(position) == 2, "position should be 2-tuple"
        position_type, amount = position
        if position_type == 'outward' and amount == 0:
            return True
        else:
            return False 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:21,代碼來源:spines.py

示例4: get_split_ind

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def get_split_ind(seq, N):
    """
    *seq* is a list of words.  Return the index into seq such that::

        len(' '.join(seq[:ind])<=N

    .
    """

    sLen = 0
    # todo: use Alex's xrange pattern from the cbook for efficiency
    for (word, ind) in zip(seq, xrange(len(seq))):
        sLen += len(word) + 1  # +1 to account for the len(' ')
        if sLen >= N:
            return ind
    return len(seq) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:cbook.py

示例5: __init__

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def __init__(self, o):
        """
        Initialize the artist inspector with an
        :class:`~matplotlib.artist.Artist` or sequence of :class:`Artists`.
        If a sequence is used, we assume it is a homogeneous sequence (all
        :class:`Artists` are of the same type) and it is your responsibility
        to make sure this is so.
        """
        if cbook.iterable(o) and len(o):
            o = o[0]

        self.oorig = o
        if not isinstance(o, type):
            o = type(o)
        self.o = o

        self.aliasd = self.get_aliases() 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:19,代碼來源:artist.py

示例6: num2date

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def num2date(x, tz=None):
    """
    *x* is a float value which gives the number of days
    (fraction part represents hours, minutes, seconds) since
    0001-01-01 00:00:00 UTC *plus* *one*.
    The addition of one here is a historical artifact.  Also, note
    that the Gregorian calendar is assumed; this is not universal
    practice.  For details, see the module docstring.

    Return value is a :class:`datetime` instance in timezone *tz* (default to
    rcparams TZ value).

    If *x* is a sequence, a sequence of :class:`datetime` objects will
    be returned.
    """
    if tz is None:
        tz = _get_rc_timezone()
    if not cbook.iterable(x):
        return _from_ordinalf(x, tz)
    else:
        return [_from_ordinalf(val, tz) for val in x] 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:23,代碼來源:dates.py

示例7: flatten

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def flatten(seq, scalarp=is_scalar_or_string):
    """
    Return a generator of flattened nested containers

    For example:

        >>> from matplotlib.cbook import flatten
        >>> l = (('John', ['Hunter']), (1, 23), [[([42, (5, 23)], )]])
        >>> print(list(flatten(l)))
        ['John', 'Hunter', 1, 23, 42, 5, 23]

    By: Composite of Holger Krekel and Luther Blissett
    From: https://code.activestate.com/recipes/121294/
    and Recipe 1.12 in cookbook
    """
    for item in seq:
        if scalarp(item) or item is None:
            yield item
        else:
            yield from flatten(item, scalarp) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:22,代碼來源:__init__.py

示例8: _warn_external

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def _warn_external(message, category=None):
    """
    `warnings.warn` wrapper that sets *stacklevel* to "outside Matplotlib".

    The original emitter of the warning can be obtained by patching this
    function back to `warnings.warn`, i.e. ``cbook._warn_external =
    warnings.warn`` (or ``functools.partial(warnings.warn, stacklevel=2)``,
    etc.).
    """
    frame = sys._getframe()
    for stacklevel in itertools.count(1):  # lgtm[py/unused-loop-variable]
        if frame is None:
            # when called in embedded context may hit frame is None
            break
        if not re.match(r"\A(matplotlib|mpl_toolkits)(\Z|\.)",
                        # Work around sphinx-gallery not setting __name__.
                        frame.f_globals.get("__name__", "")):
            break
        frame = frame.f_back
    warnings.warn(message, category, stacklevel) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:22,代碼來源:__init__.py

示例9: _print_image

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def _print_image(self, filename, format, *args, **kwargs):
        width, height = self.get_width_height()
        pixmap = gtk.gdk.Pixmap (None, width, height, depth=24)
        self._render_figure(pixmap, width, height)

        # jpg colors don't match the display very well, png colors match
        # better
        pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8,
                                width, height)
        pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
                                 0, 0, 0, 0, width, height)

        # set the default quality, if we are writing a JPEG.
        # http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#method-gdkpixbuf--save
        options = cbook.restrict_dict(kwargs, ['quality'])
        if format in ['jpg','jpeg']:
           if 'quality' not in options:
              options['quality'] = rcParams['savefig.jpeg_quality']
           options['quality'] = str(options['quality'])

        pixbuf.save(filename, format, options=options) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:23,代碼來源:backend_gdk.py

示例10: get_xticklabels

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def get_xticklabels(self, minor=False, which=None):
        """
        Get the x tick labels as a list of :class:`~matplotlib.text.Text`
        instances.

        Parameters
        ----------
        minor : bool
           If True return the minor ticklabels,
           else return the major ticklabels

        which : None, ('minor', 'major', 'both')
           Overrides `minor`.

           Selects which ticklabels to return

        Returns
        -------
        ret : list
           List of :class:`~matplotlib.text.Text` instances.
        """
        return cbook.silent_list('Text xticklabel',
                                 self.xaxis.get_ticklabels(minor=minor,
                                                           which=which)) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:26,代碼來源:_base.py

示例11: get_yticklabels

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def get_yticklabels(self, minor=False, which=None):
        """
        Get the x tick labels as a list of :class:`~matplotlib.text.Text`
        instances.

        Parameters
        ----------
        minor : bool
           If True return the minor ticklabels,
           else return the major ticklabels

        which : None, ('minor', 'major', 'both')
           Overrides `minor`.

           Selects which ticklabels to return

        Returns
        -------
        ret : list
           List of :class:`~matplotlib.text.Text` instances.
        """
        return cbook.silent_list('Text yticklabel',
                                  self.yaxis.get_ticklabels(minor=minor,
                                                            which=which)) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:26,代碼來源:_base.py

示例12: start_pan

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def start_pan(self, x, y, button):
        """
        Called when a pan operation has started.

        *x*, *y* are the mouse coordinates in display coords.
        button is the mouse button number:

        * 1: LEFT
        * 2: MIDDLE
        * 3: RIGHT

        .. note::

            Intended to be overridden by new projection types.

        """
        self._pan_start = cbook.Bunch(
            lim=self.viewLim.frozen(),
            trans=self.transData.frozen(),
            trans_inverse=self.transData.inverted().frozen(),
            bbox=self.bbox.frozen(),
            x=x,
            y=y) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:25,代碼來源:_base.py

示例13: date2num

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def date2num(d):
    """
    *d* is either a :class:`datetime` instance or a sequence of datetimes.

    Return value is a floating point number (or sequence of floats)
    which gives the number of days (fraction part represents hours,
    minutes, seconds) since 0001-01-01 00:00:00 UTC, *plus* *one*.
    The addition of one here is a historical artifact.  Also, note
    that the Gregorian calendar is assumed; this is not universal
    practice.  For details, see the module docstring.
    """
    if not cbook.iterable(d):
        return _to_ordinalf(d)
    else:
        d = np.asarray(d)
        if not d.size:
            return d
        return _to_ordinalf_np_vectorized(d) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:20,代碼來源:dates.py

示例14: num2date

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def num2date(x, tz=None):
    """
    *x* is a float value which gives the number of days
    (fraction part represents hours, minutes, seconds) since
    0001-01-01 00:00:00 UTC *plus* *one*.
    The addition of one here is a historical artifact.  Also, note
    that the Gregorian calendar is assumed; this is not universal
    practice.  For details, see the module docstring.

    Return value is a :class:`datetime` instance in timezone *tz* (default to
    rcparams TZ value).

    If *x* is a sequence, a sequence of :class:`datetime` objects will
    be returned.
    """
    if tz is None:
        tz = _get_rc_timezone()
    if not cbook.iterable(x):
        return _from_ordinalf(x, tz)
    else:
        x = np.asarray(x)
        if not x.size:
            return x
        return _from_ordinalf_np_vectorized(x, tz).tolist() 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:26,代碼來源:dates.py

示例15: flatten

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import cbook [as 別名]
def flatten(seq, scalarp=is_scalar_or_string):
    """
    Returns a generator of flattened nested containers

    For example:

        >>> from matplotlib.cbook import flatten
        >>> l = (('John', ['Hunter']), (1, 23), [[([42, (5, 23)], )]])
        >>> print(list(flatten(l)))
        ['John', 'Hunter', 1, 23, 42, 5, 23]

    By: Composite of Holger Krekel and Luther Blissett
    From: https://code.activestate.com/recipes/121294/
    and Recipe 1.12 in cookbook
    """
    for item in seq:
        if scalarp(item) or item is None:
            yield item
        else:
            yield from flatten(item, scalarp) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:22,代碼來源:__init__.py


注:本文中的matplotlib.cbook方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。