8000 Merge pull request #27457 from tacaswell/tst/tick_clear_behavior · matplotlib/matplotlib@5a9916f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5a9916f

Browse files
authored
Merge pull request #27457 from tacaswell/tst/tick_clear_behavior
TST: adding tests of current clear behavior on ticks
2 parents 0da2da0 + 5bc7c67 commit 5a9916f

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8920,3 +8920,46 @@ def test_axhvlinespan_interpolation():
89208920
ax.axhline(1, c="C0", alpha=.5)
89218921
ax.axhspan(.8, .9, fc="C1", alpha=.5)
89228922
ax.axhspan(.6, .7, .8, .9, fc="C2", alpha=.5)
8923+
8924+
8925+
@check_figures_equal(extensions=["png"])
8926+
@pytest.mark.parametrize("which", ("x", "y"))
8927+
def test_axes_clear_behavior(fig_ref, fig_test, which):
8928+
"""Test that the given tick params are not reset by ax.clear()."""
8929+
ax_test = fig_test.subplots()
8930+
ax_ref = fig_ref.subplots()
8931+
# the following tick params values are chosen to each create a visual difference
8932+
# from their defaults
8933+
target = {
8934+
"direction": "in",
8935+
"length": 10,
8936+
"width": 10,
8937+
"color": "xkcd:wine red",
8938+
"pad": 0,
8939+
"labelfontfamily": "serif",
8940+
"zorder": 7,
8941+
"labelrotation": 45,
8942+
"labelcolor": "xkcd:shocking pink",
8943+
# this overrides color + labelcolor, skip
8944+
# colors: ,
8945+
"grid_color": "xkcd:fluorescent green",
8946+
"grid_alpha": 0.5,
8947+
"grid_linewidth": 3,
8948+
"grid_linestyle": ":",
8949+
"bottom": False,
8950+
"top": True,
8951+
"left": False,
8952+
"right": True,
8953+
"labelbottom": True,
8954+
"labeltop": True,
8955+
"labelleft": True,
8956+
"labelright": True,
8957+
}
8958+
8959+
ax_ref.tick_params(axis=which, **target)
8960+
8961+
ax_test.tick_params(axis=which, **target)
8962+
ax_test.clear()
8963+
8964+
ax_ref.grid(True)
8965+
ax_test.grid(True)

0 commit comments

Comments
 (0)
0