|
11 | 11 | image_comparison, remove_ticks_and_titles)
|
12 | 12 |
|
13 | 13 | from mpl_toolkits.axes_grid1 import (
|
14 |
| - axes_size as Size, host_subplot, make_axes_locatable, AxesGrid, ImageGrid) |
| 14 | + axes_size as Size, |
| 15 | + host_subplot, make_axes_locatable, |
| 16 | + Grid, AxesGrid, ImageGrid) |
15 | 17 | from mpl_toolkits.axes_grid1.anchored_artists import (
|
16 | 18 | AnchoredSizeBar, AnchoredDirectionArrows)
|
17 | 19 | from mpl_toolkits.axes_grid1.axes_divider import HBoxDivider
|
@@ -470,3 +472,25 @@ def test_axes_class_tuple():
|
470 | 472 | fig = plt.figure()
|
471 | 473 | axes_class = (mpl_toolkits.axes_grid1.mpl_axes.Axes, {})
|
472 | 474 | gr = AxesGrid(fig, 111, nrows_ncols=(1, 1), axes_class=axes_class)
|
| 475 | + |
| 476 | + |
| 477 | +def test_grid_axes_lists(): |
| 478 | + """Test Grid axes_all, axes_row and axes_column relationship.""" |
| 479 | + fig = plt.figure() |
| 480 | + grid = Grid(fig, 111, (2, 3), direction="row") |
| 481 | + assert_array_equal(grid, grid.axes_all) |
| 482 | + assert_array_equal(grid.axes_row, np.transpose(grid.axes_column)) |
| 483 | + assert_array_equal(grid, np.ravel(grid.axes_row), "row") |
| 484 | + grid = Grid(fig, 111, (2, 3), direction="column") |
| 485 | + assert_array_equal(grid, np.ravel(grid.axes_column), "column") |
| 486 | + |
| 487 | + |
| 488 | +@pytest.mark.parametrize('direction', ('row', 'column')) |
| 489 | +def test_grid_axes_position(direction): |
| 490 | + """Test positioning of the axes in Grid.""" |
| 491 | + fig = plt.figure() |
| 492 | + grid = Grid(fig, 111, (2, 2), direction=direction) |
| 493 | + loc = [ax.get_axes_locator() for ax in np.ravel(grid.axes_row)] |
| 494 | + assert loc[1]._nx > loc[0]._nx and loc[2]._ny < loc[0]._ny |
| 495 | + assert loc[0]._nx == loc[2]._nx and loc[0]._ny == loc[1]._ny |
| 496 | + assert loc[3]._nx == loc[1]._nx and loc[3]._ny == loc[2]._ny |
0 commit comments