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

Skip to content

Commit c423658

Browse files
authored
Merge pull request #20805 from QuLogic/fix-tick-reset
FIX: Ensure all params are restored after `reset_ticks`.
2 parents 7cef121 + c304045 commit c423658

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/matplotlib/axis.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@ def __init__(self, axes, loc, *,
167167
GRIDLINE_INTERPOLATION_STEPS
168168
self.label1 = mtext.Text(
169169
np.nan, np.nan,
170-
fontsize=labelsize, color=labelcolor, visible=label1On)
170+
fontsize=labelsize, color=labelcolor, visible=label1On,
171+
rotation=self._labelrotation[1])
171172
self.label2 = mtext.Text(
172173
np.nan, np.nan,
173-
fontsize=labelsize, color=labelcolor, visible=label2On)
174+
fontsize=labelsize, color=labelcolor, visible=label2On,
175+
rotation=self._labelrotation[1])
174176

175177
self._apply_tickdir(tickdir)
176178

lib/matplotlib/tests/test_axes.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4783,6 +4783,26 @@ def test_reset_grid():
47834783
assert ax.xaxis.majorTicks[0].gridline.get_visible()
47844784

47854785

4786+
@check_figures_equal(extensions=['png'])
4787+
def test_reset_ticks(fig_test, fig_ref):
4788+
for fig in [fig_ref, fig_test]:
4789+
ax = fig.add_subplot()
4790+
ax.grid(True)
4791+
ax.tick_params(
4792+
direction='in', length=10, width=5, color='C0', pad=12,
4793+
labelsize=14, labelcolor='C1', labelrotation=45,
4794+
grid_color='C2', grid_alpha=0.8, grid_linewidth=3,
4795+
grid_linestyle='--')
4796+
fig.draw_no_output()
4797+
4798+
# After we've changed any setting on ticks, reset_ticks will mean
4799+
# re-creating them from scratch. This *should* appear the same as not
4800+
# resetting them.
4801+
for ax in fig_test.axes:
4802+
ax.xaxis.reset_ticks()
4803+
ax.yaxis.reset_ticks()
4804+
4805+
47864806
def test_vline_limit():
47874807
fig = plt.figure()
47884808
ax = fig.gca()

0 commit comments

Comments
 (0)