|
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 | from mpl_toolkits.axisartist import Axes
|
8 | 10 |
|
@@ -53,3 +55,35 @@ def test_Axes():
|
53 | 55 | ax.set_xscale('log')
|
54 | 56 |
|
55 | 57 | plt.show()
|
| 58 | + |
| 59 | + |
| 60 | +@image_comparison(baseline_images=['ParasiteAxesAuxTrans_meshplot'], |
| 61 | + extensions=['png'], remove_text=True, style='default', |
| 62 | + tol=0.05) |
| 63 | +def test_ParasiteAxesAuxTrans(): |
| 64 | + |
| 65 | + data = np.ones((6, 6)) |
| 66 | + data[2, 2] = 2 |
| 67 | + data[0, :] = 0 |
| 68 | + data[-2, :] = 0 |
| 69 | + data[:, 0] = 0 |
| 70 | + data[:, -2] = 0 |
| 71 | + x = np.arange(6) |
| 72 | + y = np.arange(6) |
| 73 | + xx, yy = np.meshgrid(x, y) |
| 74 | + |
| 75 | + funcnames = ['pcolor', 'pcolormesh', 'contourf'] |
| 76 | + |
| 77 | + fig = plt.figure() |
| 78 | + for i, name in enumerate(funcnames): |
| 79 | + |
| 80 | + ax1 = SubplotHost(fig, 1, 3, i+1) |
| 81 | + fig.add_subplot(ax1) |
| 82 | + |
| 83 | + ax2 = ParasiteAxesAuxTrans(ax1, IdentityTransform()) |
| 84 | + ax1.parasites.append(ax2) |
| 85 | + getattr(ax2, name)(xx, yy, data) |
| 86 | + ax1.set_xlim((0, 5)) |
| 87 | + ax1.set_ylim((0, 5)) |
| 88 | + |
| 89 | + ax2.contour(xx, yy, data, colors='k') |
0 commit comments