Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 53b309b

Browse filesBrowse files
authored
Merge pull request #18830 from phara92/pgf_plotting
Pgf plotting
2 parents b0dfa85 + 7ff6ded commit 53b309b
Copy full SHA for 53b309b

File tree

Expand file treeCollapse file tree

2 files changed

+16
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-6
lines changed

‎lib/matplotlib/backends/backend_pgf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pgf.py
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import re
1111
import shutil
1212
import subprocess
13-
import sys
1413
from tempfile import TemporaryDirectory
1514
import weakref
1615

@@ -101,6 +100,7 @@ def common_texification(text):
101100
# Sometimes, matplotlib adds the unknown command \mathdefault.
102101
# Not using \mathnormal instead since this looks odd for the latex cm font.
103102
text = _replace_mathdefault(text)
103+
text = text.replace("\N{MINUS SIGN}", r"\ensuremath{-}")
104104
# split text into normaltext and inline math parts
105105
parts = re_mathsep.split(text)
106106
for i, s in enumerate(parts):
@@ -792,10 +792,7 @@ def _print_pgf_to_fh(self, fh, *, bbox_inches_restore=None):
792792
%% Make sure the required packages are loaded in your preamble
793793
%% \\usepackage{pgf}
794794
%%
795-
%% and, on pdftex
796-
%% \\usepackage[utf8]{inputenc}\\DeclareUnicodeCharacter{2212}{-}
797-
%%
798-
%% or, on luatex and xetex
795+
%% and on luatex and xetex
799796
%% \\usepackage{unicode-math}
800797
%%
801798
%% Figures using additional raster images can only be included by \\input if

‎lib/matplotlib/tests/test_backend_pgf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_pgf.py
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
import matplotlib as mpl
1313
import matplotlib.pyplot as plt
1414
from matplotlib.testing.compare import compare_images, ImageComparisonFailure
15-
from matplotlib.testing.decorators import image_comparison, _image_directories
1615
from matplotlib.backends.backend_pgf import PdfPages, common_texification
16+
from matplotlib.testing.decorators import (_image_directories,
17+
check_figures_equal,
18+
image_comparison)
1719

1820
baseline_dir, result_dir = _image_directories(lambda: 'dummy func')
1921

@@ -333,3 +335,14 @@ def test_unknown_font(caplog):
333335
plt.savefig(BytesIO(), format="pgf")
334336
assert "Ignoring unknown font: this-font-does-not-exist" in [
335337
r.getMessage() for r in caplog.records]
338+
339+
340+
@check_figures_equal(extensions=["pdf"])
341+
@pytest.mark.parametrize("texsystem", ("pdflatex", "xelatex", "lualatex"))
342+
@pytest.mark.backend("pgf")
343+
def test_minus_signs_with_tex(fig_test, fig_ref, texsystem):
344+
if not check_for(texsystem):
345+
pytest.skip(texsystem + ' + pgf is required')
346+
mpl.rcParams["pgf.texsystem"] = texsystem
347+
fig_test.text(.5, .5, "$-1$")
348+
fig_ref.text(.5, .5, "$\N{MINUS SIGN}1$")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.