8000 Make Text.update_from copy usetex state. · matplotlib/matplotlib@6c76bbd · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c76bbd

Browse files
committed
Make Text.update_from copy usetex state.
This is used in particular by tick handling code to propagate text properties across ticks, so this change avoids having some ticks using usetex and others not using usetex if the rcParam value changes after axes creation.
1 parent 5cb84e0 commit 6c76bbd

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

doc/api/next_api_changes/behaviour.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ shape ``(n, 2)`` would plot the first column of *x* against the first column
7070
of *y*, the second column of *x* against the second column of *y*, **and** the
7171
first column of *x* against the third column of *y*. This now raises an error
7272
instead.
73+
74+
`.Text.update_from` now copies usetex state from the source Text
75+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lib/matplotlib/tests/test_text.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,21 @@ def test_hinting_factor_backends():
532532
rtol=0.1)
533533

534534

535+
@needs_usetex
536+
def test_usetex_is_copied():
537+
# Indirectly tests that update_from (which is used to copy tick label
538+
# properties) copies usetex state.
539+
fig = plt.figure()
540+
plt.rcParams["text.usetex"] = False
541+
ax1 = fig.add_subplot(121)
542+
plt.rcParams["text.usetex"] = True
543+
ax2 = fig.add_subplot(122)
544+
fig.canvas.draw()
545+
for ax, usetex in [(ax1, False), (ax2, True)]:
546+
for t in ax.xaxis.majorTicks:
547+
assert t.label1.get_usetex() == usetex
548+
549+
535550
@needs_usetex
536551
def test_single_artist_usetex():
537552
# Check that a single artist marked with usetex does not get passed through

lib/matplotlib/text.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def update_from(self, other):
262262
self._verticalalignment = other._verticalalignment
263263
self._horizontalalignment = other._horizontalalignment
264264
self._fontproperties = other._fontproperties.copy()
265+
self._usetex = other._usetex
265266
self._rotation = other._rotation
266267
self._picker = other._picker
267268
self._linespacing = other._linespacing

0 commit comments

Comments
 (0)
0