Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9233c44

Browse files
committed
Updated axes_grid test for more parameters
1 parent ccb53b0 commit 9233c44

1 file changed

Lines changed: 28 additions & 16 deletions

File tree

lib/mpl_toolkits/tests/test_axes_grid.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,31 @@ def test_imagegrid_cbar_mode_edge():
1212
X, Y = np.meshgrid(np.linspace(0, 6, 30), np.linspace(0, 6, 30))
1313
arr = np.sin(X) * np.cos(Y) + 1j*(np.sin(3*Y) * np.cos(Y/2.))
1414

15-
fig = plt.figure(figsize=(6, 6))
16-
17-
grid = ImageGrid(fig, 111,
18-
nrows_ncols=(2, 2),
19-
direction='row',
20-
cbar_location='right',
21-
cbar_mode='edge')
22-
ax1, ax2, ax3, ax4, = grid
23-
24-
im1 = ax1.imshow(arr.real, cmap='spectral')
25-
im2 = ax2.imshow(arr.imag, cmap='hot')
26-
im3 = ax3.imshow(np.abs(arr), cmap='jet')
27-
im4 = ax4.imshow(np.arctan2(arr.imag, arr.real), cmap='hsv')
28-
29-
ax2.cax.colorbar(im2)
30-
ax4.cax.colorbar(im4)
15+
fig = plt.figure(figsize=(18, 9))
16+
17+
positions = (241, 242, 243, 244, 245, 246, 247, 248)
18+
directions = ['row']*4 + ['column']*4
19+
cbar_locations = ['left', 'right', 'top', 'bottom']*2
20+
21+
for position, direction, location in zip(positions,
22+
directions,
23+
cbar_locations):
24+
grid = ImageGrid(fig, position,
25+
nrows_ncols=(2, 2),
26+
direction=direction,
27+
cbar_location=location,
28+
cbar_size='20%',
29+
cbar_mode='edge')
30+
ax1, ax2, ax3, ax4, = grid
31+
32+
im1 = ax1.imshow(arr.real, cmap='spectral')
33+
im2 = ax2.imshow(arr.imag, cmap='hot')
34+
im3 = ax3.imshow(np.abs(arr), cmap='jet')
35+
im4 = ax4.imshow(np.arctan2(arr.imag, arr.real), cmap='hsv')
36+
37+
# Some of these colorbars will be overridden by later ones,
38+
# depending on the direction and cbar_location
39+
ax1.cax.colorbar(im1)
40+
ax2.cax.colorbar(im2)
41+
ax3.cax.colorbar(im3)
42+
ax4.cax.colorbar(im4)

0 commit comments

Comments
 (0)