diff --git a/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst b/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst index a34615e18dee..f1dbe3b2d2e2 100644 --- a/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst +++ b/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst @@ -44,6 +44,7 @@ The following classes, methods, functions, and attributes are deprecated: The following rcParams are deprecated: - ``examples.directory`` (use ``datapath`` instead), - ``pgf.debug`` (the pgf backend relies on logging), +- ``text.latex.unicode``, The following keyword arguments are deprecated: - passing ``verts`` to ``Axes.scatter`` (use ``marker`` instead), diff --git a/doc/api/next_api_changes/2018-05-15-AL.rst b/doc/api/next_api_changes/2018-05-15-AL.rst new file mode 100644 index 000000000000..82422ec5500e --- /dev/null +++ b/doc/api/next_api_changes/2018-05-15-AL.rst @@ -0,0 +1,8 @@ +Changes regarding the text.latex.unicode rcParam +```````````````````````````````````````````````` + +The rcParam now defaults to True and is deprecated (i.e., in future versions +of Maplotlib, unicode input will always be supported). + +Moreover, the underlying implementation now uses ``\usepackage[utf8]{inputenc}`` +instead of ``\usepackage{ucs}\usepackage[utf8x]{inputenc}``. diff --git a/examples/text_labels_and_annotations/tex_demo.py b/examples/text_labels_and_annotations/tex_demo.py index 495ee4b3c583..f8683a825795 100644 --- a/examples/text_labels_and_annotations/tex_demo.py +++ b/examples/text_labels_and_annotations/tex_demo.py @@ -17,7 +17,6 @@ import numpy as np import matplotlib matplotlib.rcParams['text.usetex'] = True -matplotlib.rcParams['text.latex.unicode'] = True import matplotlib.pyplot as plt diff --git a/examples/text_labels_and_annotations/usetex_baseline_test.py b/examples/text_labels_and_annotations/usetex_baseline_test.py index 6d8b79177d17..0a72afab63e2 100644 --- a/examples/text_labels_and_annotations/usetex_baseline_test.py +++ b/examples/text_labels_and_annotations/usetex_baseline_test.py @@ -11,7 +11,6 @@ from matplotlib import rcParams rcParams['text.usetex'] = True -rcParams['text.latex.unicode'] = True class Axes(maxes.Axes): diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 29fc2f1388db..382ef4e6234c 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -820,8 +820,10 @@ def gen_candidates(): 'axes.hold': ('2.1',), 'backend.qt4': ('2.2',), 'backend.qt5': ('2.2',), + 'text.latex.unicode': ('3.0',), } + _all_deprecated = {*_deprecated_map, *_deprecated_ignore_map} @@ -881,7 +883,7 @@ 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 = None + addendum = '' if key.startswith('backend'): addendum = ( "In order to force the use of a specific Qt binding, " @@ -1241,21 +1243,33 @@ def rcdefaults(): Use a specific style file. Call ``style.use('default')`` to restore the default style. """ - rcParams.clear() - rcParams.update(rcParamsDefault) + # Deprecation warnings were already handled when creating rcParamsDefault, + # no need to reemit them here. + with warnings.catch_warnings(): + warnings.simplefilter("ignore", mplDeprecation) + rcParams.clear() + rcParams.update(rcParamsDefault) def rc_file_defaults(): """Restore the rc params from the original rc file loaded by Matplotlib. """ - rcParams.update(rcParamsOrig) + # Deprecation warnings were already handled when creating rcParamsOrig, no + # need to reemit them here. + with warnings.catch_warnings(): + warnings.simplefilter("ignore", mplDeprecation) + rcParams.update(rcParamsOrig) def rc_file(fname): """ Update rc params from file. """ - rcParams.update(rc_params_from_file(fname)) + # Deprecation warnings were already handled in rc_params_from_file, no need + # to reemit them here. + with warnings.catch_warnings(): + warnings.simplefilter("ignore", mplDeprecation) + rcParams.update(rc_params_from_file(fname)) class rc_context: diff --git a/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle b/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle index c42222ad8f19..853b3481e4c7 100644 --- a/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle @@ -109,8 +109,6 @@ text.usetex : False # use latex for all text handling. The following fo # If another font is desired which can loaded using the # LaTeX \usepackage command, please inquire at the # matplotlib mailing list -text.latex.unicode : False # use "ucs" and "inputenc" LaTeX packages for handling - # unicode strings. text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. diff --git a/lib/matplotlib/mpl-data/stylelib/classic.mplstyle b/lib/matplotlib/mpl-data/stylelib/classic.mplstyle index 94ae5bf7a4f3..6da7b07b27dd 100644 --- a/lib/matplotlib/mpl-data/stylelib/classic.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/classic.mplstyle @@ -111,8 +111,6 @@ text.usetex : False # use latex for all text handling. The following fo # If another font is desired which can loaded using the # LaTeX \usepackage command, please inquire at the # matplotlib mailing list -text.latex.unicode : False # use "ucs" and "inputenc" LaTeX packages for handling - # unicode strings. text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 594154b5e088..215b5665ee78 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1100,7 +1100,7 @@ def _validate_linestyle(ls): # text props 'text.color': ['black', validate_color], 'text.usetex': [False, validate_bool], - 'text.latex.unicode': [False, validate_bool], + 'text.latex.unicode': [True, validate_bool], 'text.latex.preamble': [[''], validate_stringlist], 'text.latex.preview': [False, validate_bool], 'text.dvipnghack': [None, validate_bool_maybe_none], diff --git a/lib/matplotlib/style/core.py b/lib/matplotlib/style/core.py index 27cc8339c242..157c26d8ff13 100644 --- a/lib/matplotlib/style/core.py +++ b/lib/matplotlib/style/core.py @@ -18,6 +18,7 @@ import matplotlib as mpl from matplotlib import rc_params_from_file, rcParamsDefault +from matplotlib.cbook import MatplotlibDeprecationWarning __all__ = ['use', 'context', 'available', 'library', 'reload_library'] @@ -98,7 +99,11 @@ def use(style): if not isinstance(style, str): _apply_style(style) elif style == 'default': - _apply_style(rcParamsDefault, warn=False) + # Deprecation warnings were already handled when creating + # rcParamsDefault, no need to reemit them here. + with warnings.catch_warnings(): + warnings.simplefilter("ignore", MatplotlibDeprecationWarning) + _apply_style(rcParamsDefault, warn=False) elif style in library: _apply_style(library[style]) else: diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index fd0d192c3e38..ca6b53346308 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -32,11 +32,11 @@ needs_ghostscript( ('ps', False, {'ps.usedistiller': 'ghostscript'})), needs_usetex(needs_ghostscript( - ('ps', False, {'text.latex.unicode': True, 'text.usetex': True}))), + ('ps', False, {'text.usetex': True}))), ('eps', False, {}), ('eps', True, {'ps.useafm': True}), needs_usetex(needs_ghostscript( - ('eps', False, {'text.latex.unicode': True, 'text.usetex': True}))), + ('eps', False, {'text.usetex': True}))), ], ids=[ 'ps', 'ps with distiller', diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index 6a0040d1e0d8..020a8b1a6f84 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -463,7 +463,8 @@ def test_if_rctemplate_is_up_to_date(): continue if k in deprecated: continue - if k.startswith(("verbose.", "examples.directory")): + if k.startswith( + ("verbose.", "examples.directory", "text.latex.unicode")): continue found = False for line in rclines: diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index 085a65f49e9a..aed767da0e76 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -203,8 +203,7 @@ def make_tex(self, tex, fontsize): if rcParams['text.latex.unicode']: unicode_preamble = r""" -\usepackage{ucs} -\usepackage[utf8x]{inputenc}""" +\usepackage[utf8]{inputenc}""" else: unicode_preamble = '' @@ -255,8 +254,7 @@ def make_tex_preview(self, tex, fontsize): if rcParams['text.latex.unicode']: unicode_preamble = r""" -\usepackage{ucs} -\usepackage[utf8x]{inputenc}""" +\usepackage[utf8]{inputenc}""" else: unicode_preamble = '' diff --git a/matplotlibrc.template b/matplotlibrc.template index cf777b901ec2..aa864b872998 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -225,8 +225,6 @@ backend : $TEMPLATE_BACKEND ## If another font is desired which can loaded using the ## LaTeX \usepackage command, please inquire at the ## matplotlib mailing list -#text.latex.unicode : False ## use "ucs" and "inputenc" LaTeX packages for handling - ## unicode strings. #text.latex.preamble : ## IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES ## AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP ## IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO.