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

Appearance settings

Commit de98877

Browse filesBrowse files
authored
Move axes_grid tests to axes_grid1 (#23861)
1 parent 64ebec3 commit de98877
Copy full SHA for de98877

File tree

Expand file treeCollapse file tree

3 files changed

+50
-56
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+50
-56
lines changed

‎lib/mpl_toolkits/tests/test_axes_grid.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/tests/test_axes_grid.py
-56Lines changed: 0 additions & 56 deletions
This file was deleted.

‎lib/mpl_toolkits/tests/test_axes_grid1.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/tests/test_axes_grid1.py
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import matplotlib as mpl
55
import matplotlib.pyplot as plt
6+
import matplotlib.ticker as mticker
67
from matplotlib import cbook
78
from matplotlib.backend_bases import MouseEvent
89
from matplotlib.colors import LogNorm
@@ -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+
def test_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+
for position, direction, location in zip(
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+
for ax in grid:
610+
ax.cax.cla()
611+
cb = ax.cax.colorbar(ax.images[0])
612+
613+
614+
def test_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+
assert isinstance(cb.locator, mticker.LogLocator)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.