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 10e8bf1

Browse filesBrowse files
authored
Merge pull request #25884 from anntzer/igcl
Correctly pass location when constructing ImageGrid colorbar.
2 parents a4d10e2 + 2590d98 commit 10e8bf1
Copy full SHA for 10e8bf1

File tree

Expand file treeCollapse file tree

4 files changed

+9
-22
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+9
-22
lines changed

‎lib/mpl_toolkits/axes_grid1/axes_grid.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/axes_grid.py
+3-12Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,14 @@ def __init__(self, *args, orientation, **kwargs):
2222
self.orientation = orientation
2323
super().__init__(*args, **kwargs)
2424

25-
def colorbar(self, mappable, *, ticks=None, **kwargs):
26-
orientation = (
27-
"horizontal" if self.orientation in ["top", "bottom"] else
28-
"vertical")
29-
cb = self.figure.colorbar(mappable, cax=self, orientation=orientation,
30-
ticks=ticks, **kwargs)
31-
return cb
25+
def colorbar(self, mappable, **kwargs):
26+
return self.figure.colorbar(
27+
mappable, cax=self, location=self.orientation, **kwargs)
3228

3329
def toggle_label(self, b):
3430
axis = self.axis[self.orientation]
3531
axis.toggle(ticklabels=b, label=b)
3632

37-
def cla(self):
38-
orientation = self.orientation
39-
super().cla()
40-
self.orientation = orientation
41-
4233

4334
_cbaraxes_class_factory = cbook._make_class_factory(CbarAxesBase, "Cbar{}")
4435

Loading

‎lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py
+6-10Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,7 @@ def test_insetposition():
701701
@image_comparison(['imagegrid_cbar_mode.png'],
702702
remove_text=True, style='mpl20', tol=0.3)
703703
def test_imagegrid_cbar_mode_edge():
704-
# Remove this line when this test image is regenerated.
705-
plt.rcParams['pcolormesh.snap'] = False
706-
707-
X, Y = np.meshgrid(np.linspace(0, 6, 30), np.linspace(0, 6, 30))
708-
arr = np.sin(X) * np.cos(Y) + 1j*(np.sin(3*Y) * np.cos(Y/2.))
704+
arr = np.arange(16).reshape((4, 4))
709705

710706
fig = plt.figure(figsize=(18, 9))
711707

@@ -721,12 +717,12 @@ def test_imagegrid_cbar_mode_edge():
721717
cbar_location=location,
722718
cbar_size='20%',
723719
cbar_mode='edge')
724-
ax1, ax2, ax3, ax4, = grid
720+
ax1, ax2, ax3, ax4 = grid
725721

726-
ax1.imshow(arr.real, cmap='nipy_spectral')
727-
ax2.imshow(arr.imag, cmap='hot')
728-
ax3.imshow(np.abs(arr), cmap='jet')
729-
ax4.imshow(np.arctan2(arr.imag, arr.real), cmap='hsv')
722+
ax1.imshow(arr, cmap='nipy_spectral')
723+
ax2.imshow(arr.T, cmap='hot')
724+
ax3.imshow(np.hypot(arr, arr.T), cmap='jet')
725+
ax4.imshow(np.arctan2(arr, arr.T), cmap='hsv')
730726

731727
# In each row/column, the "first" colorbars must be overwritten by the
732728
# "second" ones. To achieve this, clear out the axes first.

0 commit comments

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