Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita4a0925

Browse files
committed
Deprecate rcParams["datapath"] in favor of mpl.get_data_path().
The rcParam cannot be meaningfully set by the end user from theirmatplotlibrc or Python code.
1 parentc0fca72 commita4a0925

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

‎doc/api/matplotlib_configuration_api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Default values and styling
4545

4646
..autofunction::matplotlib_fname
4747

48+
..autofunction::get_data_path
49+
4850
Logging
4951
=======
5052

‎doc/api/next_api_changes/deprecations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,8 @@ is deprecated, set the offset to 0 instead.
282282
``RendererCairo.fontweights``, ``RendererCairo.fontangles``
283283
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284284
... are deprecated.
285+
286+
The ``datapath`` rcParam
287+
~~~~~~~~~~~~~~~~~~~~~~~~
288+
Use `.get_data_path` instead. (The rcParam is deprecated because it cannot be
289+
meaningfully set by an end user.) This was deprecated only in 3.2.1.

‎lib/matplotlib/__init__.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,13 @@ def get_cachedir():
507507
return_get_config_or_cache_dir(_get_xdg_cache_dir())
508508

509509

510-
def_get_data_path():
511-
"""Return the path to matplotlib data."""
510+
@_logged_cached('matplotlib data path: %s')
511+
defget_data_path():
512+
"""Return the path to Matplotlib data."""
512513

513514
path=Path(__file__).with_name("mpl-data")
514515
ifpath.is_dir():
516+
defaultParams['datapath'][0]=str(path)
515517
returnstr(path)
516518

517519
cbook.warn_deprecated(
@@ -534,18 +536,12 @@ def get_candidate_paths():
534536

535537
forpathinget_candidate_paths():
536538
ifpath.is_dir():
539+
defaultParams['datapath'][0]=str(path)
537540
returnstr(path)
538541

539542
raiseRuntimeError('Could not find the matplotlib data files')
540543

541544

542-
@_logged_cached('matplotlib data path: %s')
543-
defget_data_path():
544-
ifdefaultParams['datapath'][0]isNone:
545-
defaultParams['datapath'][0]=_get_data_path()
546-
returndefaultParams['datapath'][0]
547-
548-
549545
defmatplotlib_fname():
550546
"""
551547
Get the location of the config file.
@@ -600,6 +596,7 @@ def gen_candidates():
600596
# listed in the rcParams (not included in _all_deprecated).
601597
# Values are tuples of (version,)
602598
_deprecated_remain_as_none= {
599+
'datapath': ('3.2.1',),
603600
'animation.avconv_path': ('3.3',),
604601
'animation.avconv_args': ('3.3',),
605602
'mathtext.fallback_to_cm': ('3.3',),
@@ -841,8 +838,9 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
841838
ifkeynotin_all_deprecated])
842839
config.update(config_from_file)
843840

844-
ifconfig['datapath']isNone:
845-
config['datapath']=get_data_path()
841+
withcbook._suppress_matplotlib_deprecation_warning():
842+
ifconfig['datapath']isNone:
843+
config['datapath']=get_data_path()
846844

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

‎lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def get_sample_data(fname, asfileobj=True):
474474
475475
If the filename ends in .gz, the file is implicitly ungzipped.
476476
"""
477-
path=Path(matplotlib._get_data_path(),'sample_data',fname)
477+
path=Path(matplotlib.get_data_path(),'sample_data',fname)
478478
ifasfileobj:
479479
suffix=path.suffix.lower()
480480
ifsuffix=='.gz':

‎matplotlibrc.template

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@
9595
#toolbar: toolbar2 # {None, toolbar2}
9696
#timezone: UTC # a pytz timezone string, e.g., US/Central or Europe/Paris
9797

98-
## Where your matplotlib data lives if you installed to a non-default
99-
## location. This is where the matplotlib fonts, bitmaps, etc reside
100-
#datapath: /home/jdhunter/mpldata
101-
10298

10399
## ***************************************************************************
104100
## * LINES *

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp