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


Python matplotlib.get_configdir函数代码示例

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


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

示例1: test_install_mplstyles

    def test_install_mplstyles(self):
        """Install matplotlib style sheets."""
        config_dir = os.path.join(mpl.get_configdir(), 'stylelib')

        if os.path.isdir(config_dir):
            created_dir = False
        else:
            os.mkdir(config_dir)
            created_dir = True

        typhon_styles = [
            os.path.basename(s)
            for s
            in glob.glob(os.path.join('..', 'stylelib', '*.mplstyle'))
            ]

        before = set(os.listdir(config_dir))

        typhon.plots.install_mplstyles()

        after = set(os.listdir(config_dir))

        for sl in after - before:
            if sl in typhon_styles:
                os.remove(os.path.join(config_dir, sl))

        if created_dir:
            os.rmdir(config_dir)

        assert set(typhon_styles).issubset(set(after))
开发者ID:olemke,项目名称:typhon,代码行数:30,代码来源:test_mplstyles.py

示例2: _fetch_historical_yahoo

    def _fetch_historical_yahoo(self, ticker, date1, date2, freq=None, cachename=None):
        """matplotlib's implementation, modified to provide proxy support and frequency
        Fetch historical data for ticker between date1 and date2.  date1 and
        date2 are date or datetime instances, or (year, month, day) sequences.

        Ex:
        fh = fetch_historical_yahoo('^GSPC', (2000, 1, 1), (2001, 12, 31))

        cachename is the name of the local file cache.  If None, will
        default to the md5 hash or the url (which incorporates the ticker
        and date range)

        a file handle is returned
        """
        if freq is None or type(freq) != str:
            raise ValueError('Must enter a frequency as a string, m, w, or d')

        proxy = self._proxy
        ticker = ticker.upper()
        
        configdir = get_configdir()
        cachedir = os.path.join(configdir, 'finance.cache')

        if iterable(date1):
            d1 = (date1[1]-1, date1[2], date1[0])
        else:
            d1 = (date1.month-1, date1.day, date1.year)
        if iterable(date2):
            d2 = (date2[1]-1, date2[2], date2[0])
        else:
            d2 = (date2.month-1, date2.day, date2.year)

        urlFmt = 'http://table.finance.yahoo.com/table.csv?a=%d&b=%d&c=%d&d=%d&e=%d&f=%d&s=%s&y=0&g=%s&ignore=.csv'

        url =  urlFmt % (d1[0], d1[1], d1[2],
                         d2[0], d2[1], d2[2], ticker, freq)

        if proxy:
            proxy_support = urllib2.ProxyHandler(proxy)
            opener = urllib2.build_opener(proxy_support)
            urllib2.install_opener(opener)

        if cachename is None:
            cachename = os.path.join(cachedir, md5(url).hexdigest())
        if os.path.exists(cachename):
            fh = file(cachename)
            verbose.report('Using cachefile %s for %s'%(cachename, ticker))
        else:
            if not os.path.isdir(cachedir):
                os.mkdir(cachedir)
            urlfh = urllib2.urlopen(url)

            fh = file(cachename, 'w')
            fh.write(urlfh.read())
            fh.close()
            verbose.report('Saved %s data to cache file %s'%(ticker, cachename))
            fh = file(cachename, 'r')

        return fh
开发者ID:divieira,项目名称:covshrink,代码行数:59,代码来源:inspricehist.py

示例3: _install_matplotlib_styles

 def _install_matplotlib_styles(self):
     import matplotlib as mpl
     conf_dir = mpl.get_configdir()
     if not os.path.exists(conf_dir):
         os.mkdir(conf_dir)
     style_dir = os.path.join(conf_dir, 'stylelib')
     if not os.path.exists(style_dir):
         os.mkdir(style_dir)
     static_path = os.path.join(self._module_path(), 'static', 'styles')
     for style in os.listdir(static_path):
         target_path = os.path.join(style_dir, style)
         if not os.path.exists(target_path):
             shutil.copyfile(os.path.join(static_path, style), target_path)
开发者ID:LucksLab,项目名称:spats,代码行数:13,代码来源:tool.py

示例4: clean_cache

def clean_cache(mapdir=None, maxsize=None):
    """Clean cache directory by checking its size

    :Params:

        - **mapdir**, optional: Directory where maps are cached
        - **maxsize**, optional: Maximal size of directory in bytes.
          Default value from :confopt:`[vacumm.misc.grid.basemap]max_cache_size`
          configuration value.
    """
    from ...misc.misc import dirsize
    mapdir = get_map_dir(mapdir)
    if mapdir is None:
        mapdir = os.path.join(get_configdir(), 'basemap', 'cached_maps')
    cache_size = dirsize(mapdir)
    if maxsize is None:
        maxsize = eval(get_config_value('vacumm.misc.grid.basemap', 'max_cache_size'))
    if cache_size>maxsize:
        files = [os.path.join(mapdir, ff) for ff in os.listdir(mapdir)]
        files.sort(cmp=lambda f1, f2: cmp(os.stat(f1)[8], os.stat(f2)[8]))
        for ff in files:
            cache_size -= os.path.getsize(ff)
            os.remove(ff)
            if cache_size<=maxsize: break
开发者ID:VACUMM,项目名称:vacumm,代码行数:24,代码来源:basemap.py

示例5: get_configdir

import datetime

import numpy as np

from matplotlib import verbose, get_configdir
from matplotlib.dates import date2num
from matplotlib.cbook import iterable, mkdirs
from matplotlib.collections import LineCollection, PolyCollection
from matplotlib.colors import colorConverter
from matplotlib.lines import Line2D, TICKLEFT, TICKRIGHT
from matplotlib.patches import Rectangle
from matplotlib.transforms import Affine2D


configdir = get_configdir()
# cachedir will be None if there is no writable directory.
if configdir is not None:
    cachedir = os.path.join(configdir, 'finance.cache')
else:
    # Should only happen in a restricted environment (such as Google App
    # Engine). Deal with this gracefully by not caching finance data.
    cachedir = None


stock_dt = np.dtype([('date', object),
                     ('year', np.int16),
                     ('month', np.int8),
                     ('day', np.int8),
                     ('d', np.float),     # mpl datenum
                     ('open', np.float),
开发者ID:mgiuca-google,项目名称:matplotlib,代码行数:30,代码来源:finance.py

示例6: _remove_blacklisted_style_params

import contextlib
import os
import re
import warnings

import matplotlib as mpl
from matplotlib import rc_params_from_file, rcParamsDefault
from matplotlib.cbook import MatplotlibDeprecationWarning


__all__ = ['use', 'context', 'available', 'library', 'reload_library']


BASE_LIBRARY_PATH = os.path.join(mpl.get_data_path(), 'stylelib')
# Users may want multiple library paths, so store a list of paths.
USER_LIBRARY_PATHS = [os.path.join(mpl.get_configdir(), 'stylelib')]
STYLE_EXTENSION = 'mplstyle'
STYLE_FILE_PATTERN = re.compile(r'([\S]+).%s$' % STYLE_EXTENSION)


# A list of rcParams that should not be applied from styles
STYLE_BLACKLIST = {
    'interactive', 'backend', 'backend.qt4', 'webagg.port', 'webagg.address',
    'webagg.port_retries', 'webagg.open_in_browser', 'backend_fallback',
    'toolbar', 'timezone', 'datapath', 'figure.max_open_warning',
    'savefig.directory', 'tk.window_focus', 'docstring.hardcopy'}


def _remove_blacklisted_style_params(d, warn=True):
    o = {}
    for key, val in d.items():
开发者ID:dopplershift,项目名称:matplotlib,代码行数:31,代码来源:core.py

示例7: file

from numpy import *
import scipy.constants as con
from scipy.ndimage.filters import median_filter

from matplotlib.pyplot import *
import matplotlib.patches as patches
import matplotlib.image as mpimg

import profile

from matplotlib import rc

import dm3lib_v099 as dm3

print matplotlib.get_configdir()


print args, fullpath
# with file('log.txt', 'w') as outfile:
#    outfile.write('# Args\n')
#    outfile.write(str(args))


rc("savefig", dpi=600)
rc("xtick", direction="out")
rc("ytick", direction="out")
rc("lines", markeredgewidth=1)

print "Welcome to Diffraction Ring Profiler. This program will measure electron diffraction rings"
print " and extract intensity profiles from the diffraction pattern."
开发者ID:bcolsen,项目名称:diffraction-ring-profiler,代码行数:30,代码来源:diffraction_ring_profiler.py

示例8: print

from numpy.random import *
from matplotlib import pyplot as plt
import matplotlib as mpl
import matplotlib.font_manager as fm

print(mpl.get_configdir())
print(fm.findSystemFonts())

# 乱数生成
rand_nums = randn(100)

# 追加部分 フォントを指定する。
plt.rcParams["font.family"] = "IPAexGothic"

# ヒストグラム表示
plt.hist(rand_nums)
plt.xlabel("X軸と表示したい")
plt.ylabel("Y軸と表示したい")
plt.show()
开发者ID:hujuu,项目名称:py-test,代码行数:19,代码来源:mpl_font_test2.py

示例9:

# https://www.datacamp.com/community/tutorials/machine-learning-python
import numpy as np
from sklearn import datasets
digits = datasets.load_digits()
#print(digits)
import matplotlib
from sklearn.decomposition import RandomizedPCA
from sklearn.decomposition import PCA

print "config dir=", matplotlib.get_configdir()
matplotlib.use('TkAgg')
# the same dataset as above but from another location
#import pandas as pd
#digits = pd.read_csv("http://archive.ics.uci.edu/ml/machine-learning-databases/optdigits/optdigits.tra", header=None)
print " ---- KEYS ------"
print digits.keys()

print " ----  DATA  ----"
print digits.data

print "  == DESCR ==="
#print digits.DESCR

# Isolate the `digits` data
digits_data = digits.data

print "there are 1797 samples and that there are 64 features "
# Inspect the shape
print(digits_data.shape)

# Isolate the target values with `target`
开发者ID:mlubinsky,项目名称:mlubinsky.github.com,代码行数:31,代码来源:sci-mnist.py

示例10: repository

import jupyter_core.paths
import matplotlib as mpl


# Root directory of repository (where this file is located)
root_dir = os.path.realpath(os.path.dirname(__file__))

# Get IPython configuration directory
ipython_dir = IPython.paths.get_ipython_dir()

# Destination directories for each source directory
# (except IPython, which depends on the profile to be used...)
dest_dirs = {
	'.ipython': ipython_dir,
	'.jupyter': jupyter_core.paths.jupyter_config_dir(),
	'.matplotlib': mpl.get_configdir(),
}


# Proper function to get raw input from user in Python 2 or 3
if sys.version_info.major == 2:
	get_input = raw_input
else:
	get_input = input


# Symbolic link function for unix vs windows
try:
	symlink = os.symlink

except AttributeError:
开发者ID:jlumpe,项目名称:ipython-config,代码行数:31,代码来源:install.py

示例11:

import os
import shutil
import matplotlib as mpl

stylelib = os.path.join(mpl.get_configdir(), 'stylelib')

# in case you don't have a stylelib directory yet
try:
    os.mkdir(stylelib)

except FileExistsError:
    pass

# copy the files into the stylelib directory
[shutil.copy(f, stylelib) for f in os.listdir('.') if f.endswith('.mplstyle')]
开发者ID:nirum,项目名称:mplstyle,代码行数:15,代码来源:install.py

示例12:

from __future__ import division

import numpy as np
import pandas as pd
import matplotlib
matplotlib.get_configdir()
matplotlib.use('Agg') # Must be before importing matplotlib.pyplot or pylab!
import matplotlib.pyplot as plt

from pylab import *
from matplotlib import rcParams
from scipy import integrate

# Getting SVN number 
GIT=

# Help to find the fonts properly!
# You can find the list of fonts installed on the system with:
#fonts = "\n".join(matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext="ttf"))
#print fonts
# If Times New Roman is listed in the system, check if it is listed in python:
#print [f.name for f in matplotlib.font_manager.fontManager.ttflist]
# Maybe the python package have its own fonts folder, find it and add the file times.ttf
# Then, you need to remove the fontmanager cache so the code will read the new file
# Find the cache location with:
#print matplotlib.get_cachedir()

# Defining fonts to be used in plots
rcParams.update({'figure.autolayout': True})
rcParams.update({'font.family':'Times New Roman'})
rcParams.update({'font.size':20})
开发者ID:chandanaanand13,项目名称:fds-smv,代码行数:31,代码来源:generate_plots.py

示例13: len

# -*- coding:utf8 -*-
import matplotlib as mpl

print mpl.rcParams
print len(mpl.rcParams)
mpl.rc('lines', linewidth=2, color='r')
print mpl.get_configdir()
开发者ID:felit,项目名称:python-study,代码行数:7,代码来源:params.py

示例14: get_map_dir

def get_map_dir(mapdir=None):
    """Get the directory where cqched maps are stored"""
    if mapdir is None:
        mapdir = os.path.join(get_configdir(), 'basemap', 'cached_maps')
    return mapdir
开发者ID:VACUMM,项目名称:vacumm,代码行数:5,代码来源:basemap.py

示例15: exists

import os
import sys
from os.path import join, exists, expanduser
import matplotlib as mpl
mplrc_dir   = mpl.get_configdir()

if sys.platform.startswith('linux'):
    mplrc_dir = expanduser('~/.config/matplotlib')

# To conform with the XDG base directory standard,
# this configuration location has been deprecated on Linux,
# and the new location is now '/home/joncrall/.config'/matplotlib/.
# Please move your configuration there to ensure that matplotlib will
# continue to find it in the future.
mplrc_fpath = join(mplrc_dir, 'matplotlibrc')

mplrc_text = '''
backend      : qt4agg

'''

if not exists(mplrc_dir):
    os.makedirs(mplrc_dir)

with open(mplrc_fpath, 'w') as file_:
    file_.write(mplrc_text)

print('wrote %r' % mplrc_fpath)
开发者ID:Erotemic,项目名称:local,代码行数:28,代码来源:init_matplotlib.py


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