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

Commitc5fb275

Browse files
committed
Fix ngrids support in axes_grid.Grid().
Thiis also restores axes_row and axes_column to their behavior prior to88e0d84(which is the commit that broke ngrids support).
1 parent42472ef commitc5fb275

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

‎lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ def __init__(self, fig,
144144
axes_array[row,col]=axes_class(
145145
fig,rect,sharex=sharex,sharey=sharey)
146146
self.axes_all=axes_array.ravel(
147-
order="C"ifself._direction=="row"else"F").tolist()
148-
self.axes_column=axes_array.T.tolist()
149-
self.axes_row=axes_array.tolist()
147+
order="C"ifself._direction=="row"else"F").tolist()[:ngrids]
148+
self.axes_row=[[axforaxinrowifax]forrowinaxes_array]
149+
self.axes_column=[[axforaxincolifax]forcolinaxes_array.T]
150150
self.axes_llc=self.axes_column[0][-1]
151151

152152
self._init_locators()
@@ -256,7 +256,10 @@ def set_label_mode(self, mode):
256256
return
257257
foriinrange(self._nrows):
258258
forjinrange(self._ncols):
259-
ax=self.axes_row[i][j]
259+
try:
260+
ax=self.axes_row[i][j]
261+
exceptIndexError:
262+
continue
260263
ifisinstance(ax.axis,MethodType):
261264
bottom_axis=SimpleAxisArtist(ax.xaxis,1,ax.spines["bottom"])
262265
left_axis=SimpleAxisArtist(ax.yaxis,1,ax.spines["left"])

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,3 +792,9 @@ def test_anchored_locator_base_call():
792792
deftest_grid_with_axes_class_not_overriding_axis():
793793
Grid(plt.figure(),111, (2,2),axes_class=mpl.axes.Axes)
794794
RGBAxes(plt.figure(),111,axes_class=mpl.axes.Axes)
795+
796+
797+
deftest_grid_ngrids():
798+
fig=plt.figure()
799+
grid=Grid(fig,111, (3,3),ngrids=5)
800+
assertlen(fig.axes)==grid.ngrids==5

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp