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

BUG: fix a regression where tick direction wasn't conserved by Axis.clear()#23808

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes fromall 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
11 changes: 9 additions & 2 deletionslib/matplotlib/axis.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -846,6 +846,13 @@ def get_children(self):
return [self.label, self.offsetText,
*self.get_major_ticks(), *self.get_minor_ticks()]

# style parameters that should be preserved by reset operations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thislooks better, but I'm a bit of a loss what we actually want.

What's the policy for e.g.

  • zorder
  • the grid parameters likegrid_color

We should have an explicit statement on why we keep some parameters but not others.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I intentionally left out grid params because I have no opinion there, but I agree it should be discussed.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

zorder seemed to fit in the "visibility" theme, for which a consensus appears to have been reached. Please correct me if I am wrong.

timhoffm reacted with thumbs up emoji
_style_tick_params = [
'tick1On', 'tick2On', 'tickdir',
'label1On', 'label2On', 'labelsize', 'labelcolor', 'labelrotation',
'size', 'width', 'color', 'pad'
]

def _reset_major_tick_kw(self, keep_tick_and_label_visibility=False):
"""
Reset major tick params to defaults.
Expand All@@ -855,7 +862,7 @@ def _reset_major_tick_kw(self, keep_tick_and_label_visibility=False):
*keep_tick_and_label_visibility*.
"""
backup = {name: value for name, value in self._major_tick_kw.items()
if name in['tick1On', 'tick2On', 'label1On', 'label2On']}
if name inself.__class__._style_tick_params}
self._major_tick_kw.clear()
if keep_tick_and_label_visibility:
self._major_tick_kw.update(backup)
Expand All@@ -872,7 +879,7 @@ def _reset_minor_tick_kw(self, keep_tick_and_label_visibility=False):
*keep_tick_and_label_visibility*.
"""
backup = {name: value for name, value in self._minor_tick_kw.items()
if name in['tick1On', 'tick2On', 'label1On', 'label2On']}
if name inself.__class__._style_tick_params}
self._minor_tick_kw.clear()
if keep_tick_and_label_visibility:
self._minor_tick_kw.update(backup)
Expand Down
28 changes: 28 additions & 0 deletionslib/matplotlib/tests/test_axes.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7665,6 +7665,34 @@ def test_2dcolor_plot(fig_test, fig_ref):
axs[4].bar(np.arange(10), np.arange(10), color=color.reshape((1, -1)))


@pytest.mark.parametrize(
# separate tested parameters into two collision-free sets
# (e.g. avoid supplying *color* and *colors* at the same time)
'params',
[
dict(
direction='in', length=2, width=5, color="red", pad=0.4,
bottom=False, top=True, left=False, right=True,
labelrotation=90, labelsize=20,
),
dict(
colors="red",
bottom=True, top=True, left=True, right=True,
labelbottom=False, labeltop=True, labelleft=False, labelright=True,
)
]
)
@check_figures_equal(extensions=['png'])
def test_persistent_style_axes_clear(fig_test, fig_ref, params):
# see https://github.com/matplotlib/matplotlib/issues/23806
ax = fig_ref.subplots(1, 1)
ax.tick_params(which='both', axis='both', **params)

ax = fig_test.subplots(1, 1)
ax.tick_params(which='both', axis='both', **params)
ax.clear()


@check_figures_equal(extensions=['png'])
def test_shared_axes_clear(fig_test, fig_ref):
x = np.arange(0.0, 2*np.pi, 0.01)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp