diff --git a/doc/api/next_api_changes/behaviour.rst b/doc/api/next_api_changes/behaviour.rst index 04f223f2c14b..c38f10677595 100644 --- a/doc/api/next_api_changes/behaviour.rst +++ b/doc/api/next_api_changes/behaviour.rst @@ -70,3 +70,6 @@ shape ``(n, 2)`` would plot the first column of *x* against the first column of *y*, the second column of *x* against the second column of *y*, **and** the first column of *x* against the third column of *y*. This now raises an error instead. + +`.Text.update_from` now copies usetex state from the source Text +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index 9e76b8045dc6..6e94a9d95529 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -532,6 +532,21 @@ def test_hinting_factor_backends(): rtol=0.1) +@needs_usetex +def test_usetex_is_copied(): + # Indirectly tests that update_from (which is used to copy tick label + # properties) copies usetex state. + fig = plt.figure() + plt.rcParams["text.usetex"] = False + ax1 = fig.add_subplot(121) + plt.rcParams["text.usetex"] = True + ax2 = fig.add_subplot(122) + fig.canvas.draw() + for ax, usetex in [(ax1, False), (ax2, True)]: + for t in ax.xaxis.majorTicks: + assert t.label1.get_usetex() == usetex + + @needs_usetex def test_single_artist_usetex(): # Check that a single artist marked with usetex does not get passed through diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index a66911bd39d9..cf424010edbe 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -262,6 +262,7 @@ def update_from(self, other): self._verticalalignment = other._verticalalignment self._horizontalalignment = other._horizontalalignment self._fontproperties = other._fontproperties.copy() + self._usetex = other._usetex self._rotation = other._rotation self._picker = other._picker self._linespacing = other._linespacing