8000 Make Text.update_from copy usetex state. by anntzer · Pull Request #16359 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Make Text.update_from copy usetex state. #16359

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
Jan 29, 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
3 changes: 3 additions & 0 deletions doc/api/next_api_changes/behaviour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 changes: 15 additions & 0 deletions lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
0