Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 78db75f

Browse files
committed
TST: test that positioning works correctly
TST: add image grid test
1 parent c272624 commit 78db75f

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

‎lib/matplotlib/tests/test_axes.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5789,6 +5789,19 @@ def test_zoom_inset():
57895789
xx, rtol=1e-4)
57905790

57915791

5792+
def test_set_position():
5793+
fig, ax = plt.subplots()
5794+
ax.set_aspect(3.)
5795+
ax.set_position([0.1, 0.1, 0.4, 0.4], which='both')
5796+
assert np.allclose(ax.get_position().width, 0.1)
5797+
ax.set_aspect(2.)
5798+
ax.set_position([0.1, 0.1, 0.4, 0.4], which='original')
5799+
assert np.allclose(ax.get_position().width, 0.15)
5800+
ax.set_aspect(3.)
5801+
ax.set_position([0.1, 0.1, 0.4, 0.4], which='active')
5802+
assert np.allclose(ax.get_position().width, 0.1)
5803+
5804+
57925805
def test_spines_properbbox_after_zoom():
57935806
fig, ax = plt.subplots()
57945807
bb = ax.spines['bottom'].get_window_extent(fig.canvas.get_renderer())
3.78 KB
Loading[フレーム]

‎lib/mpl_toolkits/tests/test_axes_grid1.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from mpl_toolkits.axes_grid1 import host_subplot
66
from mpl_toolkits.axes_grid1 import make_axes_locatable
77
from mpl_toolkits.axes_grid1 import AxesGrid
8+
from mpl_toolkits.axes_grid1 import ImageGrid
89
from mpl_toolkits.axes_grid1.inset_locator import (
910
zoomed_inset_axes,
1011
mark_inset,
@@ -380,3 +381,28 @@ def test_anchored_direction_arrows_many_args():
380381
sep_x=-0.06, sep_y=-0.08, back_length=0.1, head_width=9,
381382
head_length=10, tail_width=5)
382383
ax.add_artist(direction_arrows)
384+
385+
386+
def test_axes_locatable_position():
387+
fig, ax = plt.subplots()
388+
divider = make_axes_locatable(ax)
389+
cax = divider.append_axes('right', size='5%', pad='2%')
390+
fig.canvas.draw()
391+
assert np.isclose(cax.get_position(original=False).width,
392+
0.03621495327102808)
393+
394+
395+
@image_comparison(baseline_images=['image_grid'], extensions=['png'],
396+
remove_text=True, style='mpl20',
397+
savefig_kwarg={'bbox_inches': 'tight'})
398+
def test_image_grid():
399+
# test that image grid works with bbox_inches=tight.
400+
im = np.arange(100)
401+
im.shape = 10, 10
402+
403+
fig = plt.figure(1, (4., 4.))
404+
grid = ImageGrid(fig, 111, nrows_ncols=(2, 2), axes_pad=0.1)
405+
406+
for i in range(4):
407+
grid[i].imshow(im)
408+
grid[i].set_title('test {0}{0}'.format(i))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /