热门

最新

红包

立Flag

投票

同城

我的

发布
wlcs_6305
mikes zhang
5 年前
truewlcs_6305

[Matplotlib] plt.subplots(ax = ax.flatten)
ax.flatten(): Transform n*m to 1*nm 1-D Array
fig, ax = plt.subplots(nrows=2,ncols=2,sharex='all',sharey='all')
ax = ax.flatten()

for i in range(4):
img = image[i].reshape(28, 28)
ax[i].imshow(img, cmap='Greys', interpolation='nearest')

# ax[i] is available
Without flatten()
fig, ax = plt.subplots(nrows=2,ncols=2,sharex='all',sharey='all')
for i in range(4):
img = image[i].reshape(28, 28)
ax[0, 0].imshow(img, cmap='Greys', interpolation='nearest')
ax[0, 1].imshow(img, cmap='Greys', interpolation='nearest')
ax[1, 0].imshow(img, cmap='Greys', interpolation='nearest')
ax[1, 1].imshow(img, cmap='Greys', interpolation='nearest')

# ax[i] is unavailable

正确不?

CSDN App 扫码分享
分享
评论
5
打赏
  • 复制链接
  • 举报
下一条:
Swift 基础100问系列之 112 swift如何通过数组表示公式基于lazy list comprehension(中文教程含解决方案) https://www.openswiftui.com/?p=370
立即登录