Skip to content

Ensure all params are restored after reset_ticks. #20805

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
Aug 20, 2021
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
6 changes: 4 additions & 2 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ def __init__(self, axes, loc, *,
GRIDLINE_INTERPOLATION_STEPS
self.label1 = mtext.Text(
np.nan, np.nan,
fontsize=labelsize, color=labelcolor, visible=label1On)
fontsize=labelsize, color=labelcolor, visible=label1On,
rotation=self._labelrotation[1])
self.label2 = mtext.Text(
np.nan, np.nan,
fontsize=labelsize, color=labelcolor, visible=label2On)
fontsize=labelsize, color=labelcolor, visible=label2On,
rotation=self._labelrotation[1])

self._apply_tickdir(tickdir)

Expand Down
20 changes: 20 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4779,6 +4779,26 @@ def test_reset_grid():
assert ax.xaxis.majorTicks[0].gridline.get_visible()


@check_figures_equal(extensions=['png'])
def test_reset_ticks(fig_test, fig_ref):
for fig in [fig_ref, fig_test]:
ax = fig.add_subplot()
ax.grid(True)
ax.tick_params(
direction='in', length=10, width=5, color='C0', pad=12,
labelsize=14, labelcolor='C1', labelrotation=45,
grid_color='C2', grid_alpha=0.8, grid_linewidth=3,
grid_linestyle='--')
fig.draw_no_output()

# After we've changed any setting on ticks, reset_ticks will mean
# re-creating them from scratch. This *should* appear the same as not
# resetting them.
for ax in fig_test.axes:
ax.xaxis.reset_ticks()
ax.yaxis.reset_ticks()


def test_vline_limit():
fig = plt.figure()
ax = fig.gca()
Expand Down