Skip to content

Commit c2451c6

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 c2451c6

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,8 @@ NavigationToolbar2QT.parent
376376
This attribute is deprecated. In order to access the parent window, use
377377
``toolbar.canvas.parent()``. Once the deprecation period is elapsed, it will
378378
also be accessible as ``toolbar.parent()``.
379+
380+
The ``datapath`` rcParam
381+
~~~~~~~~~~~~~~~~~~~~~~~~
382+
Use `.get_data_path` instead. (The rcParam is deprecated because it cannot be
383+
meaningfully set by an end user.) This was deprecated only in 3.2.1.

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)