Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate text.latex.preview rcParam. #17156

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
Apr 30, 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
6 changes: 6 additions & 0 deletions doc/api/api_changes_3.3/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ instead.
The unused ``animation.html_args`` rcParam and ``animation.HTMLWriter.args_key``
attribute are deprecated.

``text.latex.preview`` rcParam
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This rcParam, which controlled the use of the preview.sty LaTeX package to
align TeX string baselines, is deprecated, as Matplotlib's own dvi parser now
computes baselines just as well as preview.sty.

``SubplotSpec.get_rows_columns``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This method is deprecated. Use the ``GridSpec.nrows``, ``GridSpec.ncols``,
Expand Down
5 changes: 5 additions & 0 deletions examples/text_labels_and_annotations/usetex_baseline_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Usetex Baseline Test
====================

A test for :rc:`text.latex.preview`, a deprecated feature which relied
on the preview.sty LaTeX package to properly align TeX baselines. This
feature has been deprecated as Matplotlib's dvi parser now computes baselines
just as well as preview.sty; this example will be removed together with
:rc:`text.latex.preview` after the deprecation elapses.
"""

import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ def gen_candidates():
'mathtext.fallback_to_cm': ('3.3',),
'keymap.all_axes': ('3.3',),
'savefig.jpeg_quality': ('3.3',),
'text.latex.preview': ('3.3',),
}


Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
tex = r'\color[rgb]{%s} %s' % (color, s)

corr = 0 # w/2*(fontsize-10)/10
if mpl.rcParams['text.latex.preview']:
if dict.__getitem__(mpl.rcParams, 'text.latex.preview'):
# use baseline alignment!
pos = _nums_to_str(x-corr, y)
self.psfrag.append(
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def __init__(self, filename, dpi):
self.baseline = self._get_baseline(filename)

def _get_baseline(self, filename):
if rcParams['text.latex.preview']:
if dict.__getitem__(rcParams, 'text.latex.preview'):
baseline = Path(filename).with_suffix(".baseline")
if baseline.exists():
height, depth, width = baseline.read_bytes().split()
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/mpl-data/stylelib/classic.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURE
# beware of package collisions: color, geometry, graphicx,
# type1cm, textcomp. Adobe Postscript (PSSNFS) font packages
# may also be loaded, depending on your font settings
text.latex.preview : False

text.hinting : auto # May be one of the following:
# 'none': Perform no hinting
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/texmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def make_tex(self, tex, fontsize):
_re_vbox = re.compile(
r"MatplotlibBox:\(([\d.]+)pt\+([\d.]+)pt\)x([\d.]+)pt")

@cbook.deprecated("3.3")
def make_tex_preview(self, tex, fontsize):
"""
Generate a tex file to render the tex string at a specific font size.
Expand Down Expand Up @@ -286,7 +287,7 @@ def make_dvi(self, tex, fontsize):
Return the file name.
"""

if rcParams['text.latex.preview']:
if dict.__getitem__(rcParams, 'text.latex.preview'):
return self.make_dvi_preview(tex, fontsize)

basefile = self.get_basefile(tex, fontsize)
Expand All @@ -306,6 +307,7 @@ def make_dvi(self, tex, fontsize):

return dvifile

@cbook.deprecated("3.3")
def make_dvi_preview(self, tex, fontsize):
"""
Generate a dvi file containing latex's layout of tex string.
Expand Down Expand Up @@ -397,7 +399,7 @@ def get_text_width_height_descent(self, tex, fontsize, renderer=None):

dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1

if rcParams['text.latex.preview']:
if dict.__getitem__(rcParams, 'text.latex.preview'):
# use preview.sty
basefile = self.get_basefile(tex, fontsize)
baselinefile = '%s.baseline' % basefile
Expand Down
1 change: 0 additions & 1 deletion matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@
# type1cm, textcomp.
# Adobe Postscript (PSSNFS) font packages may also be
# loaded, depending on your font settings.
#text.latex.preview: False

#text.hinting: auto # May be one of the following:
# - none: Perform no hinting
Expand Down