Skip to content

Remove rcParams deprecated in mpl3.0/3.1. #16165

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 1 commit into from
Jan 9, 2020
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
11 changes: 11 additions & 0 deletions doc/api/next_api_changes/removals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,14 @@ Arguments
- The parameter ``usetex`` of `.TextToPath.get_text_path` has been removed.
Use ``ismath='TeX'`` instead.
- The parameter ``block`` of ``show()`` is now keyword-only.
- The parameter ``frameon`` of `.Figure.savefig` has been removed. Use
``facecolor="none"`` to get a transparent background.

rcParams
~~~~~~~~
- The ``text.latex.unicode`` rcParam has been removed, with no replacement.
Matplotlib now always supports unicode in usetex.
- The ``savefig.frameon`` rcParam has been removed. Set
:rc:`savefig.facecolor` to "none" to get a transparent background.
- The ``pgf.debug``, ``verbose.fileo`` and ``verbose.verbose.level`` rcParams,
which had no effect, have been removed.
5 changes: 1 addition & 4 deletions examples/misc/custom_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ def __init__(self, round_to=1.0):

def __call__(self, x, pos=None):
degrees = round(np.rad2deg(x) / self._round_to) * self._round_to
if rcParams['text.usetex'] and not rcParams['text.latex.unicode']:
return r"$%0.0f^\circ$" % degrees
else:
return "%0.0f\N{DEGREE SIGN}" % degrees
return f"{degrees:0.0f}\N{DEGREE SIGN}"

RESOLUTION = 75

Expand Down
5 changes: 0 additions & 5 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,17 +616,12 @@ 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 = {
'pgf.debug': ('3.0', None),
}

# rcParams deprecated; can use None to suppress warnings; remain actually
# listed in the rcParams (not included in _all_deprecated).
# Values are tuples of (version,)
_deprecated_remain_as_none = {
'text.latex.unicode': ('3.0',),
'savefig.frameon': ('3.1',),
'verbose.fileo': ('3.1',),
'verbose.level': ('3.1',),
}


Expand Down
15 changes: 0 additions & 15 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2152,14 +2152,6 @@ def savefig(self, fname, *, transparent=None, **kwargs):
"""

kwargs.setdefault('dpi', rcParams['savefig.dpi'])
if "frameon" in kwargs:
cbook.warn_deprecated("3.1", name="frameon", obj_type="kwarg",
alternative="facecolor")
frameon = kwargs.pop("frameon")
if frameon is None:
frameon = dict.__getitem__(rcParams, 'savefig.frameon')
else:
frameon = False # Won't pass "if frameon:" below.
if transparent is None:
transparent = rcParams['savefig.transparent']

Expand All @@ -2177,15 +2169,8 @@ def savefig(self, fname, *, transparent=None, **kwargs):
kwargs.setdefault('facecolor', rcParams['savefig.facecolor'])
kwargs.setdefault('edgecolor', rcParams['savefig.edgecolor'])

if frameon:
original_frameon = self.patch.get_visible()
self.patch.set_visible(frameon)

self.canvas.print_figure(fname, **kwargs)

if frameon:
self.patch.set_visible(original_frameon)

if transparent:
for ax, cc in zip(self.axes, original_axes_colors):
ax.patch.set_facecolor(cc[0])
Expand Down
6 changes: 2 additions & 4 deletions lib/matplotlib/projections/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class GeoAxes(Axes):
"""An abstract base class for geographic projections."""

class ThetaFormatter(Formatter):
"""
Used to format the theta tick labels. Converts the native
Expand All @@ -23,10 +24,7 @@ def __init__(self, round_to=1.0):

def __call__(self, x, pos=None):
degrees = round(np.rad2deg(x) / self._round_to) * self._round_to
if rcParams['text.usetex'] and not rcParams['text.latex.unicode']:
return r"$%0.0f^\circ$" % degrees
else:
return "%0.0f\N{DEGREE SIGN}" % degrees
return f"{degrees:0.0f}\N{DEGREE SIGN}"

RESOLUTION = 75

Expand Down
18 changes: 6 additions & 12 deletions lib/matplotlib/projections/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,12 @@ def __call__(self, x, pos=None):
vmin, vmax = self.axis.get_view_interval()
d = np.rad2deg(abs(vmax - vmin))
digits = max(-int(np.log10(d) - 1.5), 0)

if rcParams['text.usetex'] and not rcParams['text.latex.unicode']:
format_str = r"${value:0.{digits:d}f}^\circ$"
return format_str.format(value=np.rad2deg(x), digits=digits)
else:
# we use unicode, rather than mathtext with \circ, so
# that it will work correctly with any arbitrary font
# (assuming it has a degree sign), whereas $5\circ$
# will only work correctly with one of the supported
# math fonts (Computer Modern and STIX)
format_str = "{value:0.{digits:d}f}\N{DEGREE SIGN}"
return format_str.format(value=np.rad2deg(x), digits=digits)
# Use unicode rather than mathtext with \circ, so that it will work
# correctly with any arbitrary font (assuming it has a degree sign),
# whereas $5\circ$ will only work correctly with one of the supported
# math fonts (Computer Modern and STIX).
return ("{value:0.{digits:d}f}\N{DEGREE SIGN}"
.format(value=np.rad2deg(x), digits=digits))


class _AxisWrapper:
Expand Down
12 changes: 0 additions & 12 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,6 @@ def validate_mathtext_default(s):
'center_baseline'])


_validate_verbose = ValidateInStrings(
'verbose',
['silent', 'helpful', 'debug', 'debug-annoying'])


def validate_whiskers(s):
if s == 'range':
cbook.warn_deprecated(
Expand Down Expand Up @@ -1013,10 +1008,6 @@ def validate_webagg_address(s):
'interactive': [False, validate_bool],
'timezone': ['UTC', validate_string],

# the verbosity setting
'verbose.level': ['silent', _validate_verbose],
'verbose.fileo': ['sys.stdout', validate_string],

# line props
'lines.linewidth': [1.5, validate_float], # line width in points
'lines.linestyle': ['-', _validate_linestyle], # solid line
Expand Down Expand Up @@ -1133,7 +1124,6 @@ def validate_webagg_address(s):
# text props
'text.color': ['black', validate_color],
'text.usetex': [False, validate_bool],
'text.latex.unicode': [True, validate_bool],
'text.latex.preamble': ['', _validate_tex_preamble],
'text.latex.preview': [False, validate_bool],
'text.hinting': ['auto', validate_hinting],
Expand Down Expand Up @@ -1364,7 +1354,6 @@ def validate_webagg_address(s):
'savefig.dpi': ['figure', validate_dpi], # DPI
'savefig.facecolor': ['white', validate_color],
'savefig.edgecolor': ['white', validate_color],
'savefig.frameon': [True, validate_bool],
'savefig.orientation': ['portrait', validate_orientation],
'savefig.jpeg_quality': [95, validate_int],
# value checked by backend at runtime
Expand Down Expand Up @@ -1394,7 +1383,6 @@ def validate_webagg_address(s):
'pdf.use14corefonts': [False, validate_bool],
'pdf.fonttype': [3, validate_fonttype], # 3 (Type3) or 42 (Truetype)

'pgf.debug': [False, validate_bool], # output debug information
# choose latex application for creating pdf files (xelatex/lualatex)
'pgf.texsystem': ['xelatex', validate_pgf_texsystem],
# use matplotlib rc settings for font configuration
Expand Down
47 changes: 13 additions & 34 deletions lib/matplotlib/texmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ class TexManager:
'computer modern typewriter': ('cmtt', r'\usepackage{type1ec}')}

_rc_cache = None
_rc_cache_keys = (
('text.latex.preamble', 'text.latex.unicode', 'text.latex.preview',
'font.family') + tuple('font.' + n for n in font_families))
_rc_cache_keys = [
'text.latex.preamble', 'text.latex.preview', 'font.family',
*['font.' + n for n in font_families]]

@functools.lru_cache() # Always return the same instance.
def __new__(cls):
Expand Down Expand Up @@ -193,18 +193,15 @@ def get_custom_preamble(self):
return rcParams['text.latex.preamble']

def _get_preamble(self):
unicode_preamble = "\n".join([
r"\usepackage[utf8]{inputenc}",
r"\DeclareUnicodeCharacter{2212}{\ensuremath{-}}",
]) if rcParams["text.latex.unicode"] else ""
return "\n".join([
r"\documentclass{article}",
# Pass-through \mathdefault, which is used in non-usetex mode to
# use the default text font but was historically suppressed in
# usetex mode.
r"\newcommand{\mathdefault}[1]{#1}",
self._font_preamble,
unicode_preamble,
r"\usepackage[utf8]{inputenc}",
r"\DeclareUnicodeCharacter{2212}{\ensuremath{-}}",
self.get_custom_preamble(),
])

Expand All @@ -219,26 +216,17 @@ def make_tex(self, tex, fontsize):
fontcmd = {'sans-serif': r'{\sffamily %s}',
'monospace': r'{\ttfamily %s}'}.get(self.font_family,
r'{\rmfamily %s}')
tex = fontcmd % tex

s = r"""
Path(texfile).write_text(
r"""
%s
\usepackage[papersize={72in,72in},body={70in,70in},margin={1in,1in}]{geometry}
\pagestyle{empty}
\begin{document}
\fontsize{%f}{%f}%s
\end{document}
""" % (self._get_preamble(), fontsize, fontsize * 1.25, tex)
with open(texfile, 'wb') as fh:
if rcParams['text.latex.unicode']:
fh.write(s.encode('utf8'))
else:
try:
fh.write(s.encode('ascii'))
except UnicodeEncodeError:
_log.info("You are using unicode and latex, but have not "
"enabled the 'text.latex.unicode' rcParam.")
raise
""" % (self._get_preamble(), fontsize, fontsize * 1.25, fontcmd % tex),
encoding='utf-8')

return texfile

Expand All @@ -259,12 +247,12 @@ def make_tex_preview(self, tex, fontsize):
fontcmd = {'sans-serif': r'{\sffamily %s}',
'monospace': r'{\ttfamily %s}'}.get(self.font_family,
r'{\rmfamily %s}')
tex = fontcmd % tex

# newbox, setbox, immediate, etc. are used to find the box
# extent of the rendered text.

s = r"""
Path(texfile).write_text(
r"""
%s
\usepackage[active,showbox,tightpage]{preview}
\usepackage[papersize={72in,72in},body={70in,70in},margin={1in,1in}]{geometry}
Expand All @@ -279,17 +267,8 @@ def make_tex_preview(self, tex, fontsize):
{\fontsize{%f}{%f}%s}
\end{preview}
\end{document}
""" % (self._get_preamble(), fontsize, fontsize * 1.25, tex)
with open(texfile, 'wb') as fh:
if rcParams['text.latex.unicode']:
fh.write(s.encode('utf8'))
else:
try:
fh.write(s.encode('ascii'))
except UnicodeEncodeError:
_log.info("You are using unicode and latex, but have not "
"enabled the 'text.latex.unicode' rcParam.")
raise
""" % (self._get_preamble(), fontsize, fontsize * 1.25, fontcmd % tex),
encoding='utf-8')

return texfile

Expand Down
12 changes: 3 additions & 9 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,9 @@ def fix_minus(s):
helper method to perform such a replacement when it is enabled via
:rc:`axes.unicode_minus`.
"""
# Additionally, we disable the replacement when using usetex without
# unicode support (this is deprecated, i.e., in a future version,
# unicode support will always be enabled).
if (rcParams['axes.unicode_minus']
and (rcParams['text.latex.unicode']
or not rcParams['text.usetex'])):
return s.replace('-', '\N{MINUS SIGN}')
else:
return s
return (s.replace('-', '\N{MINUS SIGN}')
if rcParams['axes.unicode_minus']
else s)

def _set_locator(self, locator):
"""Subclasses may want to override this to set a locator."""
Expand Down