Skip to content

TST: adding tests of current clear behavior on ticks #27457

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 3 commits into from
Mar 7, 2024
Merged
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
43 changes: 43 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8898,3 +8898,46 @@ def test_axhvlinespan_interpolation():
ax.axhline(1, c="C0", alpha=.5)
ax.axhspan(.8, .9, fc="C1", alpha=.5)
ax.axhspan(.6, .7, .8, .9, fc="C2", alpha=.5)


@check_figures_equal(extensions=["png"])
@pytest.mark.parametrize("which", ("x", "y"))
def test_axes_clear_behavior(fig_ref, fig_test, which):
"""Test that the given tick params are not reset by ax.clear()."""
ax_test = fig_test.subplots()
ax_ref = fig_ref.subplots()
# the following tick params values are chosen to each create a visual difference
# from their defaults
target = {
"direction": "in",
"length": 10,
"width": 10,
"color": "xkcd:wine red",
"pad": 0,
"labelfontfamily": "serif",
"zorder": 7,
"labelrotation": 45,
"labelcolor": "xkcd:shocking pink",
# this overrides color + labelcolor, skip
# colors: ,
"grid_color": "xkcd:fluorescent green",
"grid_alpha": 0.5,
"grid_linewidth": 3,
"grid_linestyle": ":",
"bottom": False,
"top": True,
"left": False,
"right": True,
"labelbottom": True,
"labeltop": True,
"labelleft": True,
"labelright": True,
}

ax_ref.tick_params(axis=which, **target)

ax_test.tick_params(axis=which, **target)
ax_test.clear()

ax_ref.grid(True)
ax_test.grid(True)