擅长:python、mysql、java
<p>一个直接的解决方案是使用plt.subplot代替:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
lst_cmaps = ['Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds',
'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu',
'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn']
data = ((np.arange(100) % 10) * np.arange(100)).reshape(10, 10)
nxn = int(np.sqrt(len(lst_cmaps)))
plt, ax = plt.subplots(nxn, nxn)
for i, ax_ in enumerate(ax.flatten()):
ax_.imshow(data, cmap=lst_cmaps[i])
</code></pre>
<p>这将为您提供如下图像:</p>
<p><a href="https://i.stack.imgur.com/4lvoL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4lvoL.png" alt="enter image description here"/></a></p>