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

Skip to content

Commit 7255c22

Browse files
author
productivememberofsociety666
committed
Added tests for twin, twinx and twiny applied to host_subplot() axes.
1 parent ef7c674 commit 7255c22

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import matplotlib.pyplot as plt
77
from matplotlib.testing.decorators import image_comparison
8-
from mpl_toolkits.axes_grid1 import make_axes_locatable
8+
from mpl_toolkits.axes_grid1 import make_axes_locatable, host_subplot
9+
from itertools import product
910
import numpy as np
1011

1112

@@ -50,6 +51,20 @@ def test_divider_append_axes():
5051
axHistleft.yaxis.set_ticklabels(())
5152
axHistright.yaxis.set_ticklabels(())
5253

54+
55+
@image_comparison(baseline_images=['twin_axes_empty_and_removed'],
56+
extensions=["png"])
57+
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 + (" & {}".format(op) if op else ""),
65+
horizontalalignment="center", verticalalignment="center")
66+
plt.subplots_adjust(wspace=0.5, hspace=1)
67+
5368
if __name__ == '__main__':
5469
import nose
5570
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)