Python matplotlib.get_data_path() Examples
The following are 25 code examples for showing how to use matplotlib.get_data_path(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example 1
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: font_manager.py License: MIT License | 6 votes |
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)
Example 2
Project: GraphicDesignPatternByPython Author: Relph1119 File: font_manager.py License: MIT License | 6 votes |
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)
Example 3
Project: python3_ios Author: holzschu File: font_manager.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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)
Example 4
Project: python3_ios Author: holzschu File: test_rcparams.py License: BSD 3-Clause "New" or "Revised" License | 6 votes |
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()))
Example 5
Project: coffeegrindsize Author: jgagneastro File: font_manager.py License: MIT License | 6 votes |
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)
Example 6
Project: coffeegrindsize Author: jgagneastro File: test_rcparams.py License: MIT License | 6 votes |
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()))
Example 7
Project: CogAlg Author: boris-kz File: font_manager.py License: MIT License | 6 votes |
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)
Example 8
Project: Computable Author: ktraunmueller File: backend_gtk.py License: MIT License | 5 votes |
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
Example 9
Project: Computable Author: ktraunmueller File: backend_gtk3.py License: MIT License | 5 votes |
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
Example 10
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: font_manager.py License: MIT License | 5 votes |
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)
Example 11
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: backend_gtk.py License: MIT License | 5 votes |
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
Example 12
Project: matplotlib-4-abaqus Author: Solid-Mechanics File: backend_gtk3.py License: MIT License | 5 votes |
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
Example 13
Project: neural-network-animation Author: miloharper File: backend_gtk.py License: MIT License | 5 votes |
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
Example 14
Project: neural-network-animation Author: miloharper File: backend_gtk3.py License: MIT License | 5 votes |
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
Example 15
Project: GraphicDesignPatternByPython Author: Relph1119 File: font_manager.py License: MIT License | 5 votes |
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)
Example 16
Project: python3_ios Author: holzschu File: font_manager.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example 17
Project: python3_ios Author: holzschu File: test_rcparams.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example 18
Project: ImageFusion Author: pfchai File: backend_gtk.py License: MIT License | 5 votes |
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
Example 19
Project: ImageFusion Author: pfchai File: backend_gtk3.py License: MIT License | 5 votes |
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
Example 20
Project: coffeegrindsize Author: jgagneastro File: font_manager.py License: MIT License | 5 votes |
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)
Example 21
Project: coffeegrindsize Author: jgagneastro File: test_rcparams.py License: MIT License | 5 votes |
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
Example 22
Project: CogAlg Author: boris-kz File: font_manager.py License: MIT License | 5 votes |
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)
Example 23
Project: twitter-stock-recommendation Author: alvarobartt File: backend_gtk.py License: MIT License | 5 votes |
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( {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
Example 24
Project: twitter-stock-recommendation Author: alvarobartt File: test_rcparams.py License: MIT License | 5 votes |
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()))
Example 25
Project: twitter-stock-recommendation Author: alvarobartt File: test_rcparams.py License: MIT License | 5 votes |
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