欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

plt.subplot 绘画多个子图

程序员文章站 2024-02-13 20:46:46
...

子图间距 : 有时更改wspace不起作用,实际上left=0.75, bottom=0.2, right=1, top=0.6,hspace=0.1, wspace=0.0 都会影响子图间距。

 plt.subplots_adjust(left=0.75, bottom=0.2, right=1, top=0.6,hspace=0.1, wspace=0.0)

输出高清
dpi设置高一些

plt.savefig('img_Hrank.pdf',bbox_inches='tight',dpi=1000)  ```
import matplotlib.pyplot as plt
import numpy as np

import scipy.io as scio
fig = plt.figure()
path1 = '/home/zhangxin/HRankPlus-master/feature_img_conv.npy'
feature_img_conv = np.load(path1)  # (n, 3)
feature_img_conv = np.squeeze(feature_img_conv)
#dataNew = 'dataNew.mat'
#scio.savemat(dataNew, {'A':feature_img_conv})
#shape=['.','o','v','>','<','8','s','*']
for j in range(64):
  plt.subplot(8,8,j+1)
  feature_img_conv1 = (feature_img_conv[j,:,:])
  #feature_img_conv1=np.resize(feature_img_conv1,(250,200))
  plt.imshow(feature_img_conv1)
  plt.axis('off')
  plt.title(str(1+j),fontsize=1,y=-0.33)
  #plt.tight_layout()
  #plt.subplots_adjust(wspace =0.0,hspace=0.0)
  plt.subplots_adjust(left=0.75, bottom=0.2, right=1, top=0.6,hspace=0.1, wspace=0.0)
  #ax.set_title('第'+str(j))
plt.show()
plt.savefig('img_Hrank.pdf',bbox_inches='tight',dpi=1000)  ```

效果:![在这里插入图片描述](https://img-blog.csdnimg.cn/20201115000617884.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mjc2MjIzNA==,size_16,color_FFFFFF,t_70#pic_center)



相关标签: python画图 python

上一篇: 转录组分析处理流程

下一篇: URI