MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / get_sample_data

Function get_sample_data

lib/matplotlib/cbook.py:598–623  ·  view source on GitHub ↗

Return a sample data file. *fname* is a path relative to the :file:`mpl-data/sample_data` directory. If *asfileobj* is `True` return a file object, otherwise just a file path. Sample data files are stored in the 'mpl-data/sample_data' directory within the Matplotlib package.

(fname, asfileobj=True)

Source from the content-addressed store, hash-verified

596
597
598def get_sample_data(fname, asfileobj=True):
599 """
600 Return a sample data file. *fname* is a path relative to the
601 :file:`mpl-data/sample_data` directory. If *asfileobj* is `True`
602 return a file object, otherwise just a file path.
603
604 Sample data files are stored in the 'mpl-data/sample_data' directory within
605 the Matplotlib package.
606
607 If the filename ends in .gz, the file is implicitly ungzipped. If the
608 filename ends with .npy or .npz, and *asfileobj* is `True`, the file is
609 loaded with `numpy.load`.
610 """
611 path = _get_data_path('sample_data', fname)
612 if asfileobj:
613 suffix = path.suffix.lower()
614 if suffix == '.gz':
615 return gzip.open(path)
616 elif suffix in ['.npy', '.npz']:
617 return np.load(path)
618 elif suffix in ['.csv', '.xrc', '.txt']:
619 return path.open('r')
620 else:
621 return path.open('rb')
622 else:
623 return str(path)
624
625
626def _get_data_path(*args):

Callers 5

plot_pathsFunction · 0.90
demo_text_path.pyFile · 0.90
figure_title.pyFile · 0.90
stock_prices.pyFile · 0.90

Calls 2

_get_data_pathFunction · 0.85
openMethod · 0.45

Tested by 1

plot_pathsFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…