Skip to content

Commit 1d73de8

Browse files
committed
Remove deprecated rcParams.
1 parent 4dbbd22 commit 1d73de8

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-
"2.2", 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
@@ -253,12 +253,14 @@ def validate_backend(s):
253253
return backend
254254

255255

256+
@cbook.deprecated("3.1")
256257
def validate_qt4(s):
257258
if s is None:
258259
return None
259260
return ValidateInStrings("backend.qt4", ['PyQt4', 'PySide', 'PyQt4v2'])(s)
260261

261262

263+
@cbook.deprecated("3.1")
262264
def validate_qt5(s):
263265
if s is None:
264266
return None
@@ -982,13 +984,10 @@ def _validate_linestyle(ls):
982984
defaultParams = {
983985
'backend': [_auto_backend_sentinel, validate_backend],
984986
'backend_fallback': [True, validate_bool],
985-
'backend.qt4': [None, validate_qt4],
986-
'backend.qt5': [None, validate_qt5],
987987
'webagg.port': [8988, validate_int],
988988
'webagg.address': ['127.0.0.1', validate_webagg_address],
989989
'webagg.open_in_browser': [True, validate_bool],
990990
'webagg.port_retries': [50, validate_int],
991-
'nbagg.transparent': [True, validate_bool],
992991
'toolbar': ['toolbar2', validate_toolbar],
993992
'datapath': [None, validate_path_exists], # handled by
994993
# _get_data_path_cached
@@ -1117,7 +1116,6 @@ def _validate_linestyle(ls):
11171116
'text.latex.unicode': [True, validate_bool],
11181117
'text.latex.preamble': [[], validate_stringlist],
11191118
'text.latex.preview': [False, validate_bool],
1120-
'text.dvipnghack': [None, validate_bool_maybe_none],
11211119
'text.hinting': ['auto', validate_hinting],
11221120
'text.hinting_factor': [8, validate_int],
11231121
'text.antialiased': [True, validate_bool],
@@ -1401,8 +1399,6 @@ def _validate_linestyle(ls):
14011399

14021400
# set this when you want to generate hardcopy docstring
14031401
'docstring.hardcopy': [False, validate_bool],
1404-
# where plugin directory is locate
1405-
'plugins.directory': ['.matplotlib_plugins', validate_string],
14061402

14071403
'path.simplify': [True, validate_bool],
14081404
'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)