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


Python matplotlib.get_cachedir函数代码示例

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


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

示例1: get_cache_dir

def get_cache_dir():
    cachedir = mpl.get_cachedir()
    if cachedir is None:
        raise RuntimeError('Could not find a suitable configuration directory')
    cache_dir = os.path.join(cachedir, 'test_cache')
    try:
        Path(cache_dir).mkdir(parents=True, exist_ok=True)
    except IOError:
        return None
    if not os.access(cache_dir, os.W_OK):
        return None
    return cache_dir
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:12,代码来源:compare.py

示例2: is_string_like

        if not is_string_like(prop):
            prop = prop.get_fontconfig_pattern()
        cached = _fc_match_cache.get(prop)
        if cached is not None:
            return cached

        result = fc_match(prop, fontext)
        if result is None:
            result = fc_match(':', fontext)

        _fc_match_cache[prop] = result
        return result

else:
    if not 'TRAVIS' in os.environ:
        cachedir = get_cachedir()
        if cachedir is not None:
            if sys.version_info[0] >= 3:
                _fmcache = os.path.join(cachedir, 'fontList.py3k.cache')
            else:
                _fmcache = os.path.join(cachedir, 'fontList.cache')
    else:
        _fmcache = None

    fontManager = None

    def _rebuild():
        global fontManager
        fontManager = FontManager()
        if _fmcache:
            pickle_dump(fontManager, _fmcache)
开发者ID:Tkizzy,项目名称:PythonistaAppTemplate,代码行数:31,代码来源:font_manager.py

示例3:

# Unable to find font cache of matplotlib on a mac
import matplotlib
matplotlib.get_cachedir()
开发者ID:fiolbs,项目名称:code_extraction,代码行数:3,代码来源:python_22047.py

示例4: is_opentype_cff_font

def is_opentype_cff_font(filename):
    """
    Returns True if the given font is a Postscript Compact Font Format
    Font embedded in an OpenType wrapper.  Used by the PostScript and
    PDF backends that can not subset these fonts.
    """
    if os.path.splitext(filename)[1].lower() == '.otf':
        with open(filename, 'rb') as fd:
            return fd.read(4) == b"OTTO"
    else:
        return False


_get_font = lru_cache(64)(ft2font.FT2Font)
_fmcache = os.path.join(
    mpl.get_cachedir(), 'fontlist-v{}.json'.format(FontManager.__version__))
fontManager = None


def get_font(filename, hinting_factor=None):
    if hinting_factor is None:
        hinting_factor = rcParams['text.hinting_factor']
    return _get_font(filename, hinting_factor)


def _rebuild():
    global fontManager
    fontManager = FontManager()
    with cbook._lock_path(_fmcache):
        json_dump(fontManager, _fmcache)
    _log.info("generated new fontManager")
开发者ID:HubertHolin,项目名称:matplotlib,代码行数:31,代码来源:font_manager.py

示例5:

import matplotlib as mpl
print mpl.get_configdir()
print mpl.get_cachedir()
print mpl.__version__
开发者ID:markbolgiano,项目名称:gitrepo,代码行数:4,代码来源:mplTesting.py

示例6: Matplotlib

#!/usr/bin/env python
"""
Add fonts to Matplotlib (for any operating system)

1. add the new font to your operating system.
   In this example, I'll add a Chinese font to Ubuntu::

       apt install fonts-wqy-zenhei
2. Update Matplotlib font cache with this script.

HOWEVER, this didn't work for me on multiple PCs with Matplotlib 2.2.0

See https://github.com/scivision/histfeas/blob/master/Plots/FirstAuroralConjugate.py
"""
import matplotlib
# %% remove old font cache
cachepath = matplotlib.get_cachedir()


matplotlib.font_manager._rebuild()
开发者ID:scienceopen,项目名称:python-matlab-examples,代码行数:20,代码来源:matplotlib_add_font.py


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