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

Skip to content

Commit 69828e7

Browse files
committed
Tests for axes_grid.Grid
detect #20372
1 parent ea6121d commit 69828e7

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
image_comparison, remove_ticks_and_titles)
1212

1313
from mpl_toolkits.axes_grid1 import (
14-
axes_size as Size, host_subplot, make_axes_locatable, AxesGrid, ImageGrid)
14+
axes_size as Size, host_subplot, make_axes_locatable, Grid, AxesGrid, ImageGrid)
1515
from mpl_toolkits.axes_grid1.anchored_artists import (
1616
AnchoredSizeBar, AnchoredDirectionArrows)
1717
from mpl_toolkits.axes_grid1.axes_divider import HBoxDivider
@@ -470,3 +470,25 @@ def test_axes_class_tuple():
470470
fig = plt.figure()
471471
axes_class = (mpl_toolkits.axes_grid1.mpl_axes.Axes, {})
472472
gr = AxesGrid(fig, 111, nrows_ncols=(1, 1), axes_class=axes_class)
473+
474+
475+
def test_grid_axes_lists():
476+
"""Test Grid axes_all, axes_row and axes_column relationship."""
477+
fig = plt.figure()
478+
grid = Grid(fig, 111, (2, 3), direction="row")
479+
assert_array_equal(grid, grid.axes_all)
480+
assert_array_equal(grid.axes_row, np.transpose(grid.axes_column))
481+
assert_array_equal(grid, np.ravel(grid.axes_row), "row")
482+
grid = Grid(fig, 111, (2, 3), direction="column")
483+
assert_array_equal(grid, np.ravel(grid.axes_column), "column")
484+
485+
486+
def test_grid_axes_position():
487+
"""Test positioning of the axes in Grid."""
488+
fig = plt.figure()
489+
for dir in ("row", "column"):
490+
grid = Grid(fig, 111, (2, 2), direction=dir)
491+
loc = [ax.get_axes_locator() for ax in np.ravel(grid.axes_row)]
492+
assert loc[1]._nx > loc[0]._nx and loc[2]._ny < loc[0]._ny, dir
493+
assert loc[0]._nx == loc[2]._nx and loc[0]._ny == loc[1]._ny, dir
494+
assert loc[3]._nx == loc[1]._nx and loc[3]._ny == loc[2]._ny, dir

0 commit comments

Comments
 (0)