Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9fa6d83

Browse files
author
productivememberofsociety666
committed
Extended tests (visibility changes).
1 parent e89181d commit 9fa6d83

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from matplotlib.externals import six
55

6+
import matplotlib
67
import matplotlib.pyplot as plt
78
from matplotlib.testing.decorators import image_comparison
89
from mpl_toolkits.axes_grid1 import make_axes_locatable, host_subplot
@@ -55,13 +56,29 @@ def test_divider_append_axes():
5556
@image_comparison(baseline_images=['twin_axes_empty_and_removed'],
5657
extensions=["png"])
5758
def test_twin_axes_empty_and_removed():
58-
a = [ "twinx", "twiny", "twin" ]
59-
b = [ None, "remove" ]
60-
for i, (twin, op) in enumerate(product(a, b), 1):
61-
h = host_subplot(len(a), len(b), i)
62-
t = getattr(h, twin)()
63-
getattr(t, op)() if op else None
64-
h.text(0.5, 0.5, twin + (" & {0}".format(op) if op else ""),
59+
# Purely cosmetic font changes (avoid overlap)
60+
matplotlib.rcParams.update({"font.size": 8})
61+
matplotlib.rcParams.update({"xtick.labelsize": 8})
62+
matplotlib.rcParams.update({"ytick.labelsize": 8})
63+
generators = [ "twinx", "twiny", "twin" ]
64+
modifiers = [ "", "host invisible", "twin removed", "twin invisible",
65+
"twin removed\nhost invisible" ]
66+
# Unmodified host subplot at the beginning for reference
67+
h = host_subplot(len(modifiers)+1, len(generators), 2)
68+
h.text(0.5, 0.5, "host_subplot", horizontalalignment="center",
69+
verticalalignment="center")
70+
# Host subplots with various modifications (twin*, visibility) applied
71+
for i, (mod, gen) in enumerate(product(modifiers, generators),
72+
len(generators)+1):
73+
h = host_subplot(len(modifiers)+1, len(generators), i)
74+
t = getattr(h, gen)()
75+
if "twin invisible" in mod:
76+
t.axis[:].set_visible(False)
77+
if "twin removed" in mod:
78+
t.remove()
79+
if "host invisible" in mod:
80+
h.axis[:].set_visible(False)
81+
h.text(0.5, 0.5, gen + ("\n" + mod if mod else ""),
6582
horizontalalignment="center", verticalalignment="center")
6683
plt.subplots_adjust(wspace=0.5, hspace=1)
6784

0 commit comments

Comments
 (0)