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

Commitde98877

Browse files
authored
Move axes_grid tests to axes_grid1 (#23861)
1 parent64ebec3 commitde98877

File tree

3 files changed

+50
-56
lines changed

3 files changed

+50
-56
lines changed

‎lib/mpl_toolkits/tests/test_axes_grid.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

‎lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
importmatplotlibasmpl
55
importmatplotlib.pyplotasplt
6+
importmatplotlib.tickerasmticker
67
frommatplotlibimportcbook
78
frommatplotlib.backend_basesimportMouseEvent
89
frommatplotlib.colorsimportLogNorm
@@ -568,3 +569,52 @@ def test_rgb_axes():
568569
g=rng.random((5,5))
569570
b=rng.random((5,5))
570571
ax.imshow_rgb(r,g,b,interpolation='none')
572+
573+
574+
# The original version of this test relied on mpl_toolkits's slightly different
575+
# colorbar implementation; moving to matplotlib's own colorbar implementation
576+
# caused the small image comparison error.
577+
@image_comparison(['imagegrid_cbar_mode.png'],
578+
remove_text=True,style='mpl20',tol=0.3)
579+
deftest_imagegrid_cbar_mode_edge():
580+
# Remove this line when this test image is regenerated.
581+
plt.rcParams['pcolormesh.snap']=False
582+
583+
X,Y=np.meshgrid(np.linspace(0,6,30),np.linspace(0,6,30))
584+
arr=np.sin(X)*np.cos(Y)+1j*(np.sin(3*Y)*np.cos(Y/2.))
585+
586+
fig=plt.figure(figsize=(18,9))
587+
588+
positions= (241,242,243,244,245,246,247,248)
589+
directions= ['row']*4+ ['column']*4
590+
cbar_locations= ['left','right','top','bottom']*2
591+
592+
forposition,direction,locationinzip(
593+
positions,directions,cbar_locations):
594+
grid=ImageGrid(fig,position,
595+
nrows_ncols=(2,2),
596+
direction=direction,
597+
cbar_location=location,
598+
cbar_size='20%',
599+
cbar_mode='edge')
600+
ax1,ax2,ax3,ax4,=grid
601+
602+
ax1.imshow(arr.real,cmap='nipy_spectral')
603+
ax2.imshow(arr.imag,cmap='hot')
604+
ax3.imshow(np.abs(arr),cmap='jet')
605+
ax4.imshow(np.arctan2(arr.imag,arr.real),cmap='hsv')
606+
607+
# In each row/column, the "first" colorbars must be overwritten by the
608+
# "second" ones. To achieve this, clear out the axes first.
609+
foraxingrid:
610+
ax.cax.cla()
611+
cb=ax.cax.colorbar(ax.images[0])
612+
613+
614+
deftest_imagegrid():
615+
fig=plt.figure()
616+
grid=ImageGrid(fig,111,nrows_ncols=(1,1))
617+
ax=grid[0]
618+
im=ax.imshow([[1,2]],norm=mpl.colors.LogNorm())
619+
cb=ax.cax.colorbar(im)
620+
assertisinstance(cb.locator,mticker.LogLocator)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp