Python matplotlib._get_data_path() Examples
The following are 6
code examples of matplotlib._get_data_path().
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 also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example #1
Source File: __init__.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def get_sample_data(fname, asfileobj=True): """ Return a sample data file. *fname* is a path relative to the `mpl-data/sample_data` directory. If *asfileobj* is `True` return a file object, otherwise just a file path. Set the rc parameter examples.directory to the directory where we should look, if sample_data files are stored in a location different than default (which is 'mpl-data/sample_data` at the same level of 'matplotlib` Python module files). If the filename ends in .gz, the file is implicitly ungzipped. """ # Don't trigger deprecation warning when just fetching. if dict.__getitem__(matplotlib.rcParams, 'examples.directory'): root = matplotlib.rcParams['examples.directory'] else: root = os.path.join(matplotlib._get_data_path(), 'sample_data') path = os.path.join(root, fname) if asfileobj: if os.path.splitext(fname)[-1].lower() in ['.csv', '.xrc', '.txt']: mode = 'r' else: mode = 'rb' base, ext = os.path.splitext(fname) if ext == '.gz': return gzip.open(path, mode) else: return open(path, mode) else: return path
Example #2
Source File: __init__.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def get_sample_data(fname, asfileobj=True): """ Return a sample data file. *fname* is a path relative to the `mpl-data/sample_data` directory. If *asfileobj* is `True` return a file object, otherwise just a file path. Set the rc parameter examples.directory to the directory where we should look, if sample_data files are stored in a location different than default (which is 'mpl-data/sample_data` at the same level of 'matplotlib` Python module files). If the filename ends in .gz, the file is implicitly ungzipped. """ # Don't trigger deprecation warning when just fetching. if dict.__getitem__(matplotlib.rcParams, 'examples.directory'): root = matplotlib.rcParams['examples.directory'] else: root = os.path.join(matplotlib._get_data_path(), 'sample_data') path = os.path.join(root, fname) if asfileobj: if os.path.splitext(fname)[-1].lower() in ['.csv', '.xrc', '.txt']: mode = 'r' else: mode = 'rb' base, ext = os.path.splitext(fname) if ext == '.gz': return gzip.open(path, mode) else: return open(path, mode) else: return path
Example #3
Source File: __init__.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_sample_data(fname, asfileobj=True): """ Return a sample data file. *fname* is a path relative to the `mpl-data/sample_data` directory. If *asfileobj* is `True` return a file object, otherwise just a file path. Set the rc parameter examples.directory to the directory where we should look, if sample_data files are stored in a location different than default (which is 'mpl-data/sample_data` at the same level of 'matplotlib` Python module files). If the filename ends in .gz, the file is implicitly ungzipped. """ # Don't trigger deprecation warning when just fetching. if dict.__getitem__(matplotlib.rcParams, 'examples.directory'): root = matplotlib.rcParams['examples.directory'] else: root = os.path.join(matplotlib._get_data_path(), 'sample_data') path = os.path.join(root, fname) if asfileobj: if os.path.splitext(fname)[-1].lower() in ['.csv', '.xrc', '.txt']: mode = 'r' else: mode = 'rb' base, ext = os.path.splitext(fname) if ext == '.gz': return gzip.open(path, mode) else: return open(path, mode) else: return path
Example #4
Source File: __init__.py From coffeegrindsize with MIT License | 5 votes |
def get_sample_data(fname, asfileobj=True): """ Return a sample data file. *fname* is a path relative to the `mpl-data/sample_data` directory. If *asfileobj* is `True` return a file object, otherwise just a file path. Set the rc parameter examples.directory to the directory where we should look, if sample_data files are stored in a location different than default (which is 'mpl-data/sample_data` at the same level of 'matplotlib` Python module files). If the filename ends in .gz, the file is implicitly ungzipped. """ # Don't trigger deprecation warning when just fetching. if dict.__getitem__(matplotlib.rcParams, 'examples.directory'): root = matplotlib.rcParams['examples.directory'] else: root = os.path.join(matplotlib._get_data_path(), 'sample_data') path = os.path.join(root, fname) if asfileobj: if os.path.splitext(fname)[-1].lower() in ['.csv', '.xrc', '.txt']: mode = 'r' else: mode = 'rb' base, ext = os.path.splitext(fname) if ext == '.gz': return gzip.open(path, mode) else: return open(path, mode) else: return path
Example #5
Source File: __init__.py From CogAlg with MIT License | 5 votes |
def get_sample_data(fname, asfileobj=True): """ Return a sample data file. *fname* is a path relative to the `mpl-data/sample_data` directory. If *asfileobj* is `True` return a file object, otherwise just a file path. Set the rc parameter examples.directory to the directory where we should look, if sample_data files are stored in a location different than default (which is 'mpl-data/sample_data` at the same level of 'matplotlib` Python module files). If the filename ends in .gz, the file is implicitly ungzipped. """ # Don't trigger deprecation warning when just fetching. if dict.__getitem__(matplotlib.rcParams, 'examples.directory'): root = matplotlib.rcParams['examples.directory'] else: root = os.path.join(matplotlib._get_data_path(), 'sample_data') path = os.path.join(root, fname) if asfileobj: if os.path.splitext(fname)[-1].lower() in ['.csv', '.xrc', '.txt']: mode = 'r' else: mode = 'rb' base, ext = os.path.splitext(fname) if ext == '.gz': return gzip.open(path, mode) else: return open(path, mode) else: return path
Example #6
Source File: __init__.py From twitter-stock-recommendation with MIT License | 5 votes |
def get_sample_data(fname, asfileobj=True): """ Return a sample data file. *fname* is a path relative to the `mpl-data/sample_data` directory. If *asfileobj* is `True` return a file object, otherwise just a file path. Set the rc parameter examples.directory to the directory where we should look, if sample_data files are stored in a location different than default (which is 'mpl-data/sample_data` at the same level of 'matplotlib` Python module files). If the filename ends in .gz, the file is implicitly ungzipped. """ if matplotlib.rcParams['examples.directory']: root = matplotlib.rcParams['examples.directory'] else: root = os.path.join(matplotlib._get_data_path(), 'sample_data') path = os.path.join(root, fname) if asfileobj: if (os.path.splitext(fname)[-1].lower() in ('.csv', '.xrc', '.txt')): mode = 'r' else: mode = 'rb' base, ext = os.path.splitext(fname) if ext == '.gz': return gzip.open(path, mode) else: return open(path, mode) else: return path