Skip to content

Commit d5da674

Browse files
committed
Remove deprecated rcParams.
1 parent 93b80e2 commit d5da674

File tree

5 files changed

+29
-39
lines changed

5 files changed

+29
-39
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Removed rcParams
2+
````````````````
3+
4+
The following deprecated rcParams are removed:
5+
6+
- ``text.dvipnghack``,
7+
- ``nbagg.transparent`` (use :rc:`figure.facecolor` instead),
8+
- ``plugins.directory``,
9+
- ``axes.hold``,
10+
- ``backend.qt4`` and ``backend.qt5`` (set the :envvar:`QT_API` environment
11+
variable instead).
12+
13+
The associated validator functions ``rcsetup.validate_qt4`` and
14+
``validate_qt5`` are deprecated.

lib/matplotlib/__init__.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -739,19 +739,13 @@ def gen_candidates():
739739
# rcParams deprecated; some can manually be mapped to another key.
740740
# Values are tuples of (version, new_name_or_None).
741741
_deprecated_ignore_map = {
742-
'text.dvipnghack': ('2.1', None),
743-
'nbagg.transparent': ('2.2', 'figure.facecolor'),
744-
'plugins.directory': ('2.2', None),
745742
'pgf.debug': ('3.0', None),
746743
}
747744

748745
# rcParams deprecated; can use None to suppress warnings; remain actually
749746
# listed in the rcParams (not included in _all_deprecated).
750747
# Values are tuples of (version,)
751748
_deprecated_remain_as_none = {
752-
'axes.hold': ('2.1',),
753-
'backend.qt4': ('2.2',),
754-
'backend.qt5': ('2.2',),
755749
'text.latex.unicode': ('3.0',),
756750
}
757751

@@ -815,14 +809,8 @@ def __setitem__(self, key, val):
815809
val = alt_val(val)
816810
elif key in _deprecated_remain_as_none and val is not None:
817811
version, = _deprecated_remain_as_none[key]
818-
addendum = ''
819-
if key.startswith('backend'):
820-
addendum = (
821-
"In order to force the use of a specific Qt binding, "
822-
"either import that binding first, or set the QT_API "
823-
"environment variable.")
824812
cbook.warn_deprecated(
825-
version, name=key, obj_type="rcparam", addendum=addendum)
813+
version, name=key, obj_type="rcparam")
826814
elif key in _deprecated_ignore_map:
827815
version, alt_key = _deprecated_ignore_map[key]
828816
cbook.warn_deprecated(

lib/matplotlib/backends/qt_compat.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
The selection logic is as follows:
55
- if any of PyQt5, PySide2, PyQt4 or PySide have already been imported
66
(checked in that order), use it;
7-
- otherwise, if the QT_API environment variable (used by Enthought) is
8-
set, use it to determine which binding to use (but do not change the
9-
backend based on it; i.e. if the Qt4Agg backend is requested but QT_API
10-
is set to "pyqt5", then actually use Qt4 with the binding specified by
11-
``rcParams["backend.qt4"]``;
7+
- otherwise, if the QT_API environment variable (used by Enthought) is set, use
8+
it to determine which binding to use (but do not change the backend based on
9+
it; i.e. if the Qt5Agg backend is requested but QT_API is set to "pyqt4",
10+
then actually use Qt5 with PyQt5 or PySide2 (whichever can be imported);
1211
- otherwise, use whatever the rcParams indicate.
1312
"""
1413

@@ -33,31 +32,25 @@
3332
# First, check if anything is already imported.
3433
if "PyQt5" in sys.modules:
3534
QT_API = QT_API_PYQT5
36-
dict.__setitem__(rcParams, "backend.qt5", QT_API)
3735
elif "PySide2" in sys.modules:
3836
QT_API = QT_API_PYSIDE2
39-
dict.__setitem__(rcParams, "backend.qt5", QT_API)
4037
elif "PyQt4" in sys.modules:
4138
QT_API = QT_API_PYQTv2
42-
dict.__setitem__(rcParams, "backend.qt4", QT_API)
4339
elif "PySide" in sys.modules:
4440
QT_API = QT_API_PYSIDE
45-
dict.__setitem__(rcParams, "backend.qt4", QT_API)
4641
# Otherwise, check the QT_API environment variable (from Enthought). This can
4742
# only override the binding, not the backend (in other words, we check that the
4843
# requested backend actually matches).
4944
elif rcParams["backend"] in ["Qt5Agg", "Qt5Cairo"]:
50-
if QT_API_ENV == "pyqt5":
51-
dict.__setitem__(rcParams, "backend.qt5", QT_API_PYQT5)
52-
elif QT_API_ENV == "pyside2":
53-
dict.__setitem__(rcParams, "backend.qt5", QT_API_PYSIDE2)
54-
QT_API = dict.__getitem__(rcParams, "backend.qt5")
45+
if QT_API_ENV in ["pyqt5", "pyside2"]:
46+
QT_API = _ETS[QT_API_ENV]
47+
else:
48+
QT_API = None
5549
elif rcParams["backend"] in ["Qt4Agg", "Qt4Cairo"]:
56-
if QT_API_ENV == "pyqt4":
57-
dict.__setitem__(rcParams, "backend.qt4", QT_API_PYQTv2)
58-
elif QT_API_ENV == "pyside":
59-
dict.__setitem__(rcParams, "backend.qt4", QT_API_PYSIDE)
60-
QT_API = dict.__getitem__(rcParams, "backend.qt4")
50+
if QT_API_ENV in ["pyqt4", "pyside"]:
51+
QT_API = _ETS[QT_API_ENV]
52+
else:
53+
QT_API = None
6154
# A non-Qt backend was selected but we still got there (possible, e.g., when
6255
# fully manually embedding Matplotlib in a Qt app without using pyplot).
6356
else:

lib/matplotlib/rcsetup.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,14 @@ def validate_backend(s):
267267
return backend
268268

269269

270+
@cbook.deprecated("3.1")
270271
def validate_qt4(s):
271272
if s is None:
272273
return None
273274
return ValidateInStrings("backend.qt4", ['PyQt4', 'PySide', 'PyQt4v2'])(s)
274275

275276

277+
@cbook.deprecated("3.1")
276278
def validate_qt5(s):
277279
if s is None:
278280
return None
@@ -997,13 +999,10 @@ def _validate_linestyle(ls):
997999
defaultParams = {
9981000
'backend': [_auto_backend_sentinel, validate_backend],
9991001
'backend_fallback': [True, validate_bool],
1000-
'backend.qt4': [None, validate_qt4],
1001-
'backend.qt5': [None, validate_qt5],
10021002
'webagg.port': [8988, validate_int],
10031003
'webagg.address': ['127.0.0.1', validate_webagg_address],
10041004
'webagg.open_in_browser': [True, validate_bool],
10051005
'webagg.port_retries': [50, validate_int],
1006-
'nbagg.transparent': [True, validate_bool],
10071006
'toolbar': ['toolbar2', validate_toolbar],
10081007
'datapath': [None, validate_path_exists], # handled by
10091008
# _get_data_path_cached
@@ -1133,7 +1132,6 @@ def _validate_linestyle(ls):
11331132
'text.latex.unicode': [True, validate_bool],
11341133
'text.latex.preamble': ['', _validate_tex_preamble],
11351134
'text.latex.preview': [False, validate_bool],
1136-
'text.dvipnghack': [None, validate_bool_maybe_none],
11371135
'text.hinting': ['auto', validate_hinting],
11381136
'text.hinting_factor': [8, validate_int],
11391137
'text.antialiased': [True, validate_bool],
@@ -1419,8 +1417,6 @@ def _validate_linestyle(ls):
14191417

14201418
# set this when you want to generate hardcopy docstring
14211419
'docstring.hardcopy': [False, validate_bool],
1422-
# where plugin directory is locate
1423-
'plugins.directory': ['.matplotlib_plugins', validate_string],
14241420

14251421
'path.simplify': [True, validate_bool],
14261422
'path.simplify_threshold': [1.0 / 9.0, ValidateInterval(0.0, 1.0)],

lib/matplotlib/tests/test_rcparams.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def test_Bug_2543():
124124
_copy = mpl.rcParams.copy()
125125
for key in _copy:
126126
mpl.rcParams[key] = _copy[key]
127-
mpl.rcParams['text.dvipnghack'] = None
128127
with mpl.rc_context():
129128
_deep_copy = copy.deepcopy(mpl.rcParams)
130129
# real test is that this does not raise

0 commit comments

Comments
 (0)