Skip to content

Deprecate text.latex.unicode. #11381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/api/next_api_changes/2018-02-15-AL-deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
8 changes: 8 additions & 0 deletions doc/api/next_api_changes/2018-05-15-AL.rst
Original file line number Diff line number Diff line change
@@ -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}``.
1 change: 0 additions & 1 deletion examples/text_labels_and_annotations/tex_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from matplotlib import rcParams
rcParams['text.usetex'] = True
rcParams['text.latex.unicode'] = True


class Axes(maxes.Axes):
Expand Down
24 changes: 19 additions & 5 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}


Expand Down Expand Up @@ -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, "
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions lib/matplotlib/mpl-data/stylelib/classic.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
7 changes: 6 additions & 1 deletion lib/matplotlib/style/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions lib/matplotlib/texmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''

Expand Down Expand Up @@ -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 = ''

Expand Down
2 changes: 0 additions & 2 deletions matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down