diff --git a/doc/api/next_api_changes/2018-11-07-removals-AL.rst b/doc/api/next_api_changes/2018-11-07-removals-AL.rst new file mode 100644 index 000000000000..480e7dc055fb --- /dev/null +++ b/doc/api/next_api_changes/2018-11-07-removals-AL.rst @@ -0,0 +1,14 @@ +Removed rcParams +```````````````` + +The following deprecated rcParams are removed: + +- ``text.dvipnghack``, +- ``nbagg.transparent`` (use :rc:`figure.facecolor` instead), +- ``plugins.directory``, +- ``axes.hold``, +- ``backend.qt4`` and ``backend.qt5`` (set the :envvar:`QT_API` environment + variable instead). + +The associated validator functions ``rcsetup.validate_qt4`` and +``validate_qt5`` are deprecated. diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 97c7fd5f05be..64e4f91e5682 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -612,9 +612,6 @@ def gen_candidates(): # rcParams deprecated; some can manually be mapped to another key. # Values are tuples of (version, new_name_or_None). _deprecated_ignore_map = { - 'text.dvipnghack': ('2.1', None), - 'nbagg.transparent': ('2.2', 'figure.facecolor'), - 'plugins.directory': ('2.2', None), 'pgf.debug': ('3.0', None), } @@ -622,9 +619,6 @@ def gen_candidates(): # listed in the rcParams (not included in _all_deprecated). # Values are tuples of (version,) _deprecated_remain_as_none = { - 'axes.hold': ('2.1',), - 'backend.qt4': ('2.2',), - 'backend.qt5': ('2.2',), 'text.latex.unicode': ('3.0',), } @@ -688,14 +682,8 @@ def __setitem__(self, key, val): val = alt_val(val) elif key in _deprecated_remain_as_none and val is not None: version, = _deprecated_remain_as_none[key] - addendum = '' - if key.startswith('backend'): - addendum = ( - "In order to force the use of a specific Qt binding, " - "either import that binding first, or set the QT_API " - "environment variable.") cbook.warn_deprecated( - version, name=key, obj_type="rcparam", addendum=addendum) + version, name=key, obj_type="rcparam") elif key in _deprecated_ignore_map: version, alt_key = _deprecated_ignore_map[key] cbook.warn_deprecated( diff --git a/lib/matplotlib/backends/qt_compat.py b/lib/matplotlib/backends/qt_compat.py index 7df88d7e0d20..1198305aea73 100644 --- a/lib/matplotlib/backends/qt_compat.py +++ b/lib/matplotlib/backends/qt_compat.py @@ -4,11 +4,10 @@ The selection logic is as follows: - if any of PyQt5, PySide2, PyQt4 or PySide have already been imported (checked in that order), use it; -- otherwise, if the QT_API environment variable (used by Enthought) is - set, use it to determine which binding to use (but do not change the - backend based on it; i.e. if the Qt4Agg backend is requested but QT_API - is set to "pyqt5", then actually use Qt4 with the binding specified by - ``rcParams["backend.qt4"]``; +- otherwise, if the QT_API environment variable (used by Enthought) is set, use + it to determine which binding to use (but do not change the backend based on + it; i.e. if the Qt5Agg backend is requested but QT_API is set to "pyqt4", + then actually use Qt5 with PyQt5 or PySide2 (whichever can be imported); - otherwise, use whatever the rcParams indicate. """ @@ -33,31 +32,25 @@ # First, check if anything is already imported. if "PyQt5" in sys.modules: QT_API = QT_API_PYQT5 - dict.__setitem__(rcParams, "backend.qt5", QT_API) elif "PySide2" in sys.modules: QT_API = QT_API_PYSIDE2 - dict.__setitem__(rcParams, "backend.qt5", QT_API) elif "PyQt4" in sys.modules: QT_API = QT_API_PYQTv2 - dict.__setitem__(rcParams, "backend.qt4", QT_API) elif "PySide" in sys.modules: QT_API = QT_API_PYSIDE - dict.__setitem__(rcParams, "backend.qt4", QT_API) # Otherwise, check the QT_API environment variable (from Enthought). This can # only override the binding, not the backend (in other words, we check that the # requested backend actually matches). elif rcParams["backend"] in ["Qt5Agg", "Qt5Cairo"]: - if QT_API_ENV == "pyqt5": - dict.__setitem__(rcParams, "backend.qt5", QT_API_PYQT5) - elif QT_API_ENV == "pyside2": - dict.__setitem__(rcParams, "backend.qt5", QT_API_PYSIDE2) - QT_API = dict.__getitem__(rcParams, "backend.qt5") + if QT_API_ENV in ["pyqt5", "pyside2"]: + QT_API = _ETS[QT_API_ENV] + else: + QT_API = None elif rcParams["backend"] in ["Qt4Agg", "Qt4Cairo"]: - if QT_API_ENV == "pyqt4": - dict.__setitem__(rcParams, "backend.qt4", QT_API_PYQTv2) - elif QT_API_ENV == "pyside": - dict.__setitem__(rcParams, "backend.qt4", QT_API_PYSIDE) - QT_API = dict.__getitem__(rcParams, "backend.qt4") + if QT_API_ENV in ["pyqt4", "pyside"]: + QT_API = _ETS[QT_API_ENV] + else: + QT_API = None # A non-Qt backend was selected but we still got there (possible, e.g., when # fully manually embedding Matplotlib in a Qt app without using pyplot). else: diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index f51a22cda18e..c327b3f3031c 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -267,12 +267,14 @@ def validate_backend(s): return backend +@cbook.deprecated("3.1") def validate_qt4(s): if s is None: return None return ValidateInStrings("backend.qt4", ['PyQt4', 'PySide', 'PyQt4v2'])(s) +@cbook.deprecated("3.1") def validate_qt5(s): if s is None: return None @@ -993,13 +995,10 @@ def _validate_linestyle(ls): defaultParams = { 'backend': [_auto_backend_sentinel, validate_backend], 'backend_fallback': [True, validate_bool], - 'backend.qt4': [None, validate_qt4], - 'backend.qt5': [None, validate_qt5], 'webagg.port': [8988, validate_int], 'webagg.address': ['127.0.0.1', validate_webagg_address], 'webagg.open_in_browser': [True, validate_bool], 'webagg.port_retries': [50, validate_int], - 'nbagg.transparent': [True, validate_bool], 'toolbar': ['toolbar2', validate_toolbar], 'datapath': [None, validate_path_exists], # handled by # _get_data_path_cached @@ -1129,7 +1128,6 @@ def _validate_linestyle(ls): 'text.latex.unicode': [True, validate_bool], 'text.latex.preamble': ['', _validate_tex_preamble], 'text.latex.preview': [False, validate_bool], - 'text.dvipnghack': [None, validate_bool_maybe_none], 'text.hinting': ['auto', validate_hinting], 'text.hinting_factor': [8, validate_int], 'text.antialiased': [True, validate_bool], @@ -1415,8 +1413,6 @@ def _validate_linestyle(ls): # set this when you want to generate hardcopy docstring 'docstring.hardcopy': [False, validate_bool], - # where plugin directory is locate - 'plugins.directory': ['.matplotlib_plugins', validate_string], 'path.simplify': [True, validate_bool], 'path.simplify_threshold': [1.0 / 9.0, ValidateInterval(0.0, 1.0)], diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index e2177d1ccfc3..123ffe4ae3c3 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -124,7 +124,6 @@ def test_Bug_2543(): _copy = mpl.rcParams.copy() for key in _copy: mpl.rcParams[key] = _copy[key] - mpl.rcParams['text.dvipnghack'] = None with mpl.rc_context(): _deep_copy = copy.deepcopy(mpl.rcParams) # real test is that this does not raise