|
1 | 1 | import numpy as np
|
2 | 2 | import matplotlib.pyplot as plt
|
3 | 3 | from matplotlib.testing.decorators import image_comparison
|
| 4 | +from matplotlib.transforms import IdentityTransform |
4 | 5 |
|
5 | 6 | from mpl_toolkits.axisartist.axislines import SubplotZero, Subplot
|
6 |
| - |
| 7 | +from mpl_toolkits.axisartist import SubplotHost, ParasiteAxesAuxTrans |
7 | 8 |
|
8 | 9 | @image_comparison(baseline_images=['SubplotZero'],
|
9 | 10 | extensions=['png'], style='default')
|
@@ -40,3 +41,36 @@ def test_Subplot():
|
40 | 41 | ax.axis["bottom"].major_ticks.set_tick_out(True)
|
41 | 42 |
|
42 | 43 | ax.axis["bottom"].set_label("Tk0")
|
| 44 | + |
| 45 | + |
| 46 | +@image_comparison(baseline_images=['ParasiteAxesAuxTrans_pcolor', |
| 47 | + 'ParasiteAxesAuxTrans_pcolormesh', |
| 48 | + 'ParasiteAxesAuxTrans_contour', |
| 49 | + 'ParasiteAxesAuxTrans_contourf'], |
| 50 | + extensions=['png']) |
| 51 | +def test_ParasiteAxesAuxTrans(): |
| 52 | + |
| 53 | + data = np.ones((6, 6)) |
| 54 | + data[2, 2] = 2 |
| 55 | + data[0, :] = 0 |
| 56 | + data[-2, :] = 0 |
| 57 | + data[:, 0] = 0 |
| 58 | + data[:, -2] = 0 |
| 59 | + x = np.arange(6) |
| 60 | + y = np.arange(6) |
| 61 | + xx, yy = np.meshgrid(x, y) |
| 62 | + |
| 63 | + funcnames = ['pcolor', 'pcolormesh', 'contour', 'contourf'] |
| 64 | + |
| 65 | + for name in funcnames: |
| 66 | + fig = plt.figure() |
| 67 | + |
| 68 | + ax1 = SubplotHost(fig, 1, 1, 1) |
| 69 | + fig.add_subplot(ax1) |
| 70 | + |
| 71 | + ax2 = ParasiteAxesAuxTrans(ax1, IdentityTransform()) |
| 72 | + ax1.parasites.append(ax2) |
| 73 | + |
| 74 | + getattr(ax2, name)(xx, yy, data) |
| 75 | + ax1.set_xlim((0, 5)) |
| 76 | + ax1.set_ylim((0, 5)) |
0 commit comments