Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2811043

Browse files
authored
Merge pull request#28676 from meeseeksmachine/auto-backport-of-pr-28577-on-v3.9.x
Backport PR#28577 on branch v3.9.x (Copy all internals from initial Tick to lazy ones)
2 parents3a1c655 +1bb9c02 commit2811043

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

‎lib/matplotlib/axis.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@
3333
_gridline_param_names= ['grid_'+name
3434
fornamein_line_param_names+_line_param_aliases]
3535

36-
_MARKER_DICT= {
37-
'out': (mlines.TICKDOWN,mlines.TICKUP),
38-
'in': (mlines.TICKUP,mlines.TICKDOWN),
39-
'inout': ('|','|'),
40-
}
41-
4236

4337
classTick(martist.Artist):
4438
"""
@@ -204,18 +198,21 @@ def _set_labelrotation(self, labelrotation):
204198
_api.check_in_list(['auto','default'],labelrotation=mode)
205199
self._labelrotation= (mode,angle)
206200

201+
@property
202+
def_pad(self):
203+
returnself._base_pad+self.get_tick_padding()
204+
207205
def_apply_tickdir(self,tickdir):
208206
"""Set tick direction. Valid values are 'out', 'in', 'inout'."""
209-
# This method is responsible forupdating `_pad`, and, in subclasses,
210-
#for settingthe tick{1,2}line markers as well. From the user
211-
#perspective this should always becalled through _apply_params, which
212-
#further updates ticklabel positions usingthe new pads.
207+
# This method is responsible forverifying input and, in subclasses, for setting
208+
# the tick{1,2}line markers. From the user perspective this should always be
209+
# called through _apply_params, which further updates ticklabel positions using
210+
# the new pads.
213211
iftickdirisNone:
214212
tickdir=mpl.rcParams[f'{self.__name__}.direction']
215213
else:
216214
_api.check_in_list(['in','out','inout'],tickdir=tickdir)
217215
self._tickdir=tickdir
218-
self._pad=self._base_pad+self.get_tick_padding()
219216

220217
defget_tickdir(self):
221218
returnself._tickdir
@@ -425,7 +422,11 @@ def _get_text2_transform(self):
425422
def_apply_tickdir(self,tickdir):
426423
# docstring inherited
427424
super()._apply_tickdir(tickdir)
428-
mark1,mark2=_MARKER_DICT[self._tickdir]
425+
mark1,mark2= {
426+
'out': (mlines.TICKDOWN,mlines.TICKUP),
427+
'in': (mlines.TICKUP,mlines.TICKDOWN),
428+
'inout': ('|','|'),
429+
}[self._tickdir]
429430
self.tick1line.set_marker(mark1)
430431
self.tick2line.set_marker(mark2)
431432

@@ -1617,6 +1618,14 @@ def _copy_tick_props(self, src, dest):
16171618
dest.tick1line.update_from(src.tick1line)
16181619
dest.tick2line.update_from(src.tick2line)
16191620
dest.gridline.update_from(src.gridline)
1621+
dest.update_from(src)
1622+
dest._loc=src._loc
1623+
dest._size=src._size
1624+
dest._width=src._width
1625+
dest._base_pad=src._base_pad
1626+
dest._labelrotation=src._labelrotation
1627+
dest._zorder=src._zorder
1628+
dest._tickdir=src._tickdir
16201629

16211630
defget_label_text(self):
16221631
"""Get the text of the label."""

‎lib/matplotlib/tests/test_axes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5631,6 +5631,28 @@ def test_reset_ticks(fig_test, fig_ref):
56315631
ax.yaxis.reset_ticks()
56325632

56335633

5634+
@mpl.style.context('mpl20')
5635+
deftest_context_ticks():
5636+
withplt.rc_context({
5637+
'xtick.direction':'in','xtick.major.size':30,'xtick.major.width':5,
5638+
'xtick.color':'C0','xtick.major.pad':12,
5639+
'xtick.bottom':True,'xtick.top':True,
5640+
'xtick.labelsize':14,'xtick.labelcolor':'C1'}):
5641+
fig,ax=plt.subplots()
5642+
# Draw outside the context so that all-but-first tick are generated with the normal
5643+
# mpl20 style in place.
5644+
fig.draw_without_rendering()
5645+
5646+
first_tick=ax.xaxis.majorTicks[0]
5647+
fortickinax.xaxis.majorTicks[1:]:
5648+
asserttick._size==first_tick._size
5649+
asserttick._width==first_tick._width
5650+
asserttick._base_pad==first_tick._base_pad
5651+
asserttick._labelrotation==first_tick._labelrotation
5652+
asserttick._zorder==first_tick._zorder
5653+
asserttick._tickdir==first_tick._tickdir
5654+
5655+
56345656
deftest_vline_limit():
56355657
fig=plt.figure()
56365658
ax=fig.gca()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp