|
3 | 3 |
|
4 | 4 | from matplotlib.externals import six
|
5 | 5 |
|
| 6 | +import matplotlib |
6 | 7 | import matplotlib.pyplot as plt
|
7 | 8 | from matplotlib.testing.decorators import image_comparison
|
8 | 9 | from mpl_toolkits.axes_grid1 import make_axes_locatable, host_subplot
|
@@ -55,13 +56,29 @@ def test_divider_append_axes():
|
55 | 56 | @image_comparison(baseline_images=['twin_axes_empty_and_removed'],
|
56 | 57 | extensions=["png"])
|
57 | 58 | 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 ""), |
65 | 82 | horizontalalignment="center", verticalalignment="center")
|
66 | 83 | plt.subplots_adjust(wspace=0.5, hspace=1)
|
67 | 84 |
|
|
0 commit comments