Skip to content
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)