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

Skip to content

Commit c40a7f9

Browse files
committed
Added a test for usetex+EngFormatter
1 parent 61a0cdd commit c40a7f9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/matplotlib/tests/test_usetex.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import matplotlib
66
from matplotlib.testing.decorators import image_comparison
77
import matplotlib.pyplot as plt
8+
from matplotlib.ticker import EngFormatter
89

910

1011
with warnings.catch_warnings():
@@ -31,3 +32,18 @@ def test_usetex():
3132
fontsize=24)
3233
ax.set_xticks([])
3334
ax.set_yticks([])
35+
36+
37+
@needs_usetex
38+
def test_usetex_engformatter():
39+
matplotlib.rcParams['text.usetex'] = True
40+
fig, ax = plt.subplots()
41+
ax.plot([0, 500, 1000], [0, 500, 1000])
42+
ax.set_xticks([0, 500, 1000])
43+
formatter = EngFormatter()
44+
ax.xaxis.set_major_formatter(formatter)
45+
fig.canvas.draw()
46+
x_tick_label_text = [label.get_text() for label in ax.get_xticklabels()]
47+
# Checking if the dollar `$` signs have been inserted around numbers
48+
# in tick label text.
49+
assert x_tick_label_text == ['$0$', '$500$', '$1$ k']

0 commit comments

Comments
 (0)