2020
10-08
10-08
使用pyplot.matshow()函数添加绘图标题
仅供参考importmatplotlib.pyplotaspltimportnumpyasnpdefsamplemat(dims):"""Makeamatrixwithallzerosandincreasingelementsonthediagonal"""aa=np.zeros(dims)foriinrange(min(dims)):aa[i,i]=ireturnaafig=plt.figure()ax=fig.add_subplot(111)plt.title('titleaaa')ax.matshow(samplemat((15,15)),cmap='viridis')plt.show()补充知识:给某数组a通过plt.matshow(a)方法得到的热图h...
继续阅读 >