|
5 | 5 |
|
6 | 6 | import matplotlib.pyplot as plt
|
7 | 7 | 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 |
9 | 10 | import numpy as np
|
10 | 11 |
|
11 | 12 |
|
@@ -50,6 +51,20 @@ def test_divider_append_axes():
|
50 | 51 | axHistleft.yaxis.set_ticklabels(())
|
51 | 52 | axHistright.yaxis.set_ticklabels(())
|
52 | 53 |
|
| 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 | + |
53 | 68 | if __name__ == '__main__':
|
54 | 69 | import nose
|
55 | 70 | nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
|
0 commit comments