本文整理汇总了Python中matplotlib.get_data_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_data_path函数的具体用法?Python get_data_path怎么用?Python get_data_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_data_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_if_rctemplate_is_up_to_date
def test_if_rctemplate_is_up_to_date():
# This tests if the matplotlibrc.template file contains all valid rcParams.
deprecated = {*mpl._all_deprecated, *mpl._deprecated_remain_as_none}
path_to_rc = os.path.join(mpl.get_data_path(), 'matplotlibrc')
with open(path_to_rc, "r") as f:
rclines = f.readlines()
missing = {}
for k, v in mpl.defaultParams.items():
if k[0] == "_":
continue
if k in deprecated:
continue
if k.startswith(
("verbose.", "examples.directory", "text.latex.unicode")):
continue
found = False
for line in rclines:
if k in line:
found = True
if not found:
missing.update({k: v})
if missing:
raise ValueError("The following params are missing in the "
"matplotlibrc.template file: {}"
.format(missing.items()))
示例2: test_if_rctemplate_would_be_valid
def test_if_rctemplate_would_be_valid(tmpdir):
# This tests if the matplotlibrc.template file would result in a valid
# rc file if all lines are uncommented.
path_to_rc = os.path.join(mpl.get_data_path(), 'matplotlibrc')
with open(path_to_rc, "r") as f:
rclines = f.readlines()
newlines = []
for line in rclines:
if line[0] == "#":
newline = line[1:]
else:
newline = line
if "$TEMPLATE_BACKEND" in newline:
newline = "backend : Agg"
if "datapath" in newline:
newline = ""
newlines.append(newline)
d = tmpdir.mkdir('test1')
fname = str(d.join('testrcvalid.temp'))
with open(fname, "w") as f:
f.writelines(newlines)
with pytest.warns(None) as record:
mpl.rc_params_from_file(fname,
fail_on_error=True,
use_default_template=False)
assert len(record) == 0
示例3: __init__
def __init__(self, lines):
import gtk.glade
datadir = matplotlib.get_data_path()
gladefile = os.path.join(datadir, 'lineprops.glade')
if not os.path.exists(gladefile):
raise IOError('Could not find gladefile lineprops.glade in %s'%datadir)
self._inited = False
self._updateson = True # suppress updates when setting widgets manually
self.wtree = gtk.glade.XML(gladefile, 'dialog_lineprops')
self.wtree.signal_autoconnect(dict([(s, getattr(self, s)) for s in self.signals]))
self.dlg = self.wtree.get_widget('dialog_lineprops')
self.lines = lines
cbox = self.wtree.get_widget('combobox_lineprops')
cbox.set_active(0)
self.cbox_lineprops = cbox
cbox = self.wtree.get_widget('combobox_linestyles')
for ls in self.linestyles:
cbox.append_text(ls)
cbox.set_active(0)
self.cbox_linestyles = cbox
cbox = self.wtree.get_widget('combobox_markers')
for m in self.markers:
cbox.append_text(m)
cbox.set_active(0)
self.cbox_markers = cbox
self._lastcnt = 0
self._inited = True
示例4: test_if_rctemplate_is_up_to_date
def test_if_rctemplate_is_up_to_date():
# This tests if the matplotlibrc.template file
# contains all valid rcParams.
dep1 = mpl._all_deprecated
dep2 = mpl._deprecated_set
deprecated = list(dep1.union(dep2))
path_to_rc = os.path.join(mpl.get_data_path(), 'matplotlibrc')
with open(path_to_rc, "r") as f:
rclines = f.readlines()
missing = {}
for k, v in mpl.defaultParams.items():
if k[0] == "_":
continue
if k in deprecated:
continue
if "verbose" in k:
continue
found = False
for line in rclines:
if k in line:
found = True
if not found:
missing.update({k: v})
if missing:
raise ValueError("The following params are missing " +
"in the matplotlibrc.template file: {}"
.format(missing.items()))
示例5: recipe_matplotlib
def recipe_matplotlib(mf):
m = mf.findNode('matplotlib')
if not isRealModule(m):
return
import matplotlib
if 0: # do not copy matplotlibdata. assume matplotlib is installed as egg
dp = matplotlib.get_data_path()
assert dp
mf.copyTree(dp, "matplotlibdata", m)
# mf.import_hook("matplotlib.numerix.random_array", m)
backend_name = 'backend_' + matplotlib.get_backend().lower()
print "recipe_matplotlib: using the %s matplotlib backend" % (backend_name, )
mf.import_hook('matplotlib.backends.' + backend_name, m)
return True
示例6: default
def default(self, o):
if isinstance(o, FontManager):
return dict(o.__dict__, __class__='FontManager')
elif isinstance(o, FontEntry):
d = dict(o.__dict__, __class__='FontEntry')
try:
# Cache paths of fonts shipped with mpl relative to the mpl
# data path, which helps in the presence of venvs.
d["fname"] = str(
Path(d["fname"]).relative_to(mpl.get_data_path()))
except ValueError:
pass
return d
else:
return super().default(o)
示例7: _json_decode
def _json_decode(o):
cls = o.pop('__class__', None)
if cls is None:
return o
elif cls == 'FontManager':
r = FontManager.__new__(FontManager)
r.__dict__.update(o)
return r
elif cls == 'FontEntry':
r = FontEntry.__new__(FontEntry)
r.__dict__.update(o)
if not os.path.isabs(r.fname):
r.fname = os.path.join(mpl.get_data_path(), r.fname)
return r
else:
raise ValueError("don't know how to deserialize __class__=%s" % cls)
示例8: recipe_matplotlib
def recipe_matplotlib(mf):
m = mf.findNode('matplotlib')
if not isRealModule(m):
return
import matplotlib
if 0: # do not copy matplotlibdata. assume matplotlib is installed as egg
dp = matplotlib.get_data_path()
assert dp
mf.copyTree(dp, "matplotlibdata", m)
mf.import_hook("matplotlib.numerix.random_array", m)
# the import hook expects a string (matplotlib in later versions has
# all rcParams, including the backend as unicode)
backend_name = 'backend_' + str(matplotlib.get_backend().lower())
print "recipe_matplotlib: using the %s matplotlib backend" % (backend_name, )
mf.import_hook('matplotlib.backends.' + backend_name, m)
return True
示例9: __init__
def __init__(self, data_source, figure_size, fontsize):
self.data_source = data_source
if iterable(figure_size):
self.figure_size = float(figure_size[0]), float(figure_size[1])
else:
self.figure_size = float(figure_size)
self.plots = PlotDictionary(data_source)
self._callbacks = []
self._field_transform = {}
self._colormaps = defaultdict(lambda: 'algae')
font_path = matplotlib.get_data_path() + '/fonts/ttf/STIXGeneral.ttf'
self._font_properties = FontProperties(size=fontsize, fname=font_path)
self._font_color = None
self._xlabel = None
self._ylabel = None
self._minorticks = {}
self._cbar_minorticks = {}
self._colorbar_label = PlotDictionary(
self.data_source, lambda: None)
示例10: _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):
示例11: __init__
class Target:
def __init__(self, **kw):
self.__dict__.update(kw)
# for the versioninfo resources
self.version = local_config.__version__
self.company_name = "SasView.org"
self.copyright = "copyright 2009 - 2016"
self.name = "SasView"
#
# Adapted from http://www.py2exe.org/index.cgi/MatPlotLib
# to use the MatPlotLib.
#
path = os.getcwd()
matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)
DATA_FILES = []
if tinycc:
DATA_FILES += tinycc.data_files()
# Copying SLD data
import periodictable
DATA_FILES += periodictable.data_files()
from sas.sasgui.perspectives import fitting
DATA_FILES += fitting.data_files()
from sas.sasgui.perspectives import calculator
示例12: get_egg_dir
# Include packages not detected by cx_Freeze
includes = ['matplotlib.backends.backend_qt4agg',
'scipy.special._ufuncs_cxx',
'scipy.sparse.csgraph._validation',
#'scipy.sparse.linalg.dsolve.umfpack',
'scipy.integrate.vode',
'scipy.integrate.lsoda'
]
# includes += ['skimage.io._plugins.'+modname
# for __, modname, __ in
# pkgutil.iter_modules(skimage.io._plugins.__path__) ]
# Include data/package files not accounted for by cx_Freeze
import matplotlib
include_files = [(matplotlib.get_data_path(), 'mpl-data'),
('matplotlibrc', '')]
#A simple util to get the egg dir name
def get_egg_dir(name):
base_name = pkg_resources.get_distribution(name).egg_name()
for posible_extention in ['.egg-info','.dist-info']:
full_path = os.path.join(SITE_PACKAGE_DIR , base_name + posible_extention)
print full_path
if os.path.exists(full_path):
return base_name+posible_extention
def get_pth_dir(name):
return pkg_resources.get_distribution(name).egg_name()+'-nspkg.pth'
示例13: new_figure_manager
except:
print >>sys.stderr, 'The CococaAgg backend required PyObjC to be installed!'
print >>sys.stderr, ' (currently testing v1.3.7)'
sys.exit()
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder, AppHelper
import matplotlib
from matplotlib.figure import Figure
from matplotlib.backend_bases import FigureManagerBase
from backend_agg import FigureCanvasAgg
from matplotlib._pylab_helpers import Gcf
mplBundle = NSBundle.bundleWithPath_(matplotlib.get_data_path())
def new_figure_manager(num, *args, **kwargs):
thisFig = Figure( *args, **kwargs )
canvas = FigureCanvasCocoaAgg(thisFig)
return FigureManagerCocoaAgg(canvas, num)
def show():
for manager in Gcf.get_all_fig_managers():
manager.show()
def draw_if_interactive():
if matplotlib.is_interactive():
figManager = Gcf.get_active()
if figManager is not None:
figManager.show()
示例14:
x,y = tup[1:]
path.line_to(x,y)
elif code == CURVE3:
xctl, yctl, xto, yto= tup[1:]
path.curve3(xctl, yctl, xto, yto)
elif code == CURVE4:
xctl1, yctl1, xctl2, yctl2, xto, yto= tup[1:]
path.curve4(xctl1, yct1, xctl2, yctl2, xto, yto)
elif code == ENDPOLY:
path.end_poly()
return path
width, height = 300,300
fname = os.path.join(matplotlib.get_data_path(), 'Vera.ttf')
font = FT2Font(fname)
glyph = font.load_char(ord('y'))
path = glyph_to_agg_path(glyph)
curve = agg.conv_curve_path(path)
scaling = agg.trans_affine_scaling(20,20)
translation = agg.trans_affine_translation(4,4)
rotation = agg.trans_affine_rotation(3.1415926)
mtrans = translation*scaling # cannot use this as a temporary
tpath = agg.conv_transform_path(path, mtrans)
curve = agg.conv_curve_trans(tpath)
示例15:
'libwebkitgtk-3.0-0.dll',
'libwebp-5.dll',
'libwinpthread-1.dll',
'libxslt-1.dll',
'libzzz.dll',
]
include_files = []
for dll in missing_dlls:
include_files.append((os.path.join(include_dll_path, dll), dll))
gtk_libs = ['etc', 'lib', 'share']
for lib in gtk_libs:
include_files.append((os.path.join(include_dll_path, lib), lib))
include_files.append((matplotlib.get_data_path(), 'mpl-data'))
include_files.append((basemap.basemap_datadir, 'mpl-basemap-data'))
include_files.append(('data/client/king_phisher', 'king_phisher'))
exe_base = 'Win32GUI'
if is_debugging_build:
exe_base = 'Console'
executables = [
Executable(
'KingPhisher',
base=exe_base,
icon='data/client/king_phisher/king-phisher-icon.ico',
shortcutName='KingPhisher',
shortcutDir='ProgramMenuFolder'
)