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