Movatterモバイル変換


[0]ホーム

URL:


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

Commita518ddf

Browse files
committed
TST: test that positioning works correctly
TST: add image grid test
1 parent922cd71 commita518ddf

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+
deftest_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+
assertnp.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+
assertnp.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+
assertnp.allclose(ax.get_position().width,0.1)
5803+
5804+
57925805
deftest_spines_properbbox_after_zoom():
57935806
fig,ax=plt.subplots()
57945807
bb=ax.spines['bottom'].get_window_extent(fig.canvas.get_renderer())

‎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
frommpl_toolkits.axes_grid1importhost_subplot
66
frommpl_toolkits.axes_grid1importmake_axes_locatable
77
frommpl_toolkits.axes_grid1importAxesGrid
8+
frommpl_toolkits.axes_grid1importImageGrid
89
frommpl_toolkits.axes_grid1.inset_locatorimport (
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+
deftest_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+
assertnp.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+
deftest_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+
foriinrange(4):
407+
grid[i].imshow(im)
408+
grid[i].set_title('test {0}{0}'.format(i))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp