Skip to content

Commit 0cf039c

Browse files
committed
Deprecate rcParams["datapath"] in favor of mpl.get_data_path().
The rcParam cannot be meaningfully set by the end user from their matplotlibrc or Python code.
1 parent bb7f9b9 commit 0cf039c

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

doc/api/next_api_changes/removals.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ rcParams
179179
- The ``pgf.debug``, ``verbose.fileo`` and ``verbose.verbose.level`` rcParams,
180180
which had no effect, have been removed.
181181
- Support for setting :rc:`mathtext.default` to "circled" has been removed.
182+
- The ``datapath`` rcParam has been removed. Use `.get_data_path` instead.
182183

183184
Environment variables
184185
~~~~~~~~~~~~~~~~~~~~~

lib/matplotlib/__init__.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -509,29 +509,8 @@ def get_cachedir():
509509

510510

511511
@_logged_cached('matplotlib data path: %s')
512-
def get_data_path(*, _from_rc=None):
512+
def get_data_path():
513513
"""Return the path to Matplotlib data."""
514-
if _from_rc is not None:
515-
cbook.warn_deprecated(
516-
"3.2",
517-
message=("Setting the datapath via matplotlibrc is deprecated "
518-
"%(since)s and will be removed in %(removal)s."),
519-
removal='3.3')
520-
path = Path(_from_rc)
521-
if path.is_dir():
522-
defaultParams['datapath'][0] = str(path)
523-
return str(path)
524-
else:
525-
warnings.warn(f"You passed datapath: {_from_rc!r} in your "
526-
f"matplotribrc file ({matplotlib_fname()}). "
527-
"However this path does not exist, falling back "
528-
"to standard paths.")
529-
530-
return _get_data_path()
531-
532-
533-
@_logged_cached('(private) matplotlib data path: %s')
534-
def _get_data_path():
535514
path = Path(__file__).with_name("mpl-data")
536515
if path.is_dir():
537516
defaultParams['datapath'][0] = str(path)
@@ -594,7 +573,7 @@ def gen_candidates():
594573
yield matplotlibrc
595574
yield os.path.join(matplotlibrc, 'matplotlibrc')
596575
yield os.path.join(get_configdir(), 'matplotlibrc')
597-
yield os.path.join(_get_data_path(), 'matplotlibrc')
576+
yield os.path.join(get_data_path(), 'matplotlibrc')
598577

599578
for fname in gen_candidates():
600579
if os.path.exists(fname) and not os.path.isdir(fname):
@@ -861,10 +840,7 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
861840
config.update(config_from_file)
862841

863842
with cbook._suppress_matplotlib_deprecation_warning():
864-
if config['datapath'] is None:
865-
config['datapath'] = _get_data_path()
866-
else:
867-
config['datapath'] = get_data_path(_from_rc=config['datapath'])
843+
config['datapath'] = get_data_path()
868844

869845
if "".join(config['text.latex.preamble']):
870846
_log.info("""

0 commit comments

Comments
 (0)