如何解决如何连接两个不同的图igraph 和 matplotlib 图-python
ig.plot( test,bBox=(800,800),margin = 20,vertex_color = [color_dict1[vl] for vl in test.vs["cluster_id"]],edge_curved=True,edge_color= 'silver',vertex_size= 6,layout='fr',target=ax)
而且,我使用以下代码制作了顶级集群 ID 的图例图:
fig = plt.figure(figsize=(1,1))
plt.axis('off')
plt.rcParams["font.family"] = "serif"
for cl,col,perc in list(list_cl_perc1[:20]):
plt.scatter([],[],c=col,label='Cluster {} ({}%)'.format(int(cl),perc),s=300,figure=fig)
#legend_x = 1
#legend_y = 1 #bBox_to_anchor=(legend_x,legend_y)
plt.legend(title= 'Top 20 Clusters',loc='best',prop={'size': 17},ncol=1,title_fontsize=17,frameon=False,framealpha=1)
plt.savefig('legend.png',bBox_inches='tight',dpi=100)
plt.show()
在我使用以下方法连接这两个结果后:
import sys
from PIL import Image
images = [Image.open(x) for x in ['plots.png','legend.png']]
widths,heights = zip(*(i.size for i in images))
total_width = sum(widths)
max_height = max(heights)
new_im = Image.new('RGB',(total_width,max_height))
x_offset = 0
for im in images:
new_im.paste(im,(x_offset,0))
x_offset += im.size[0]
new_im.save('test.jpg')
'concat' 后的结果: final
我想知道是否有关于“如何在不导出的情况下连接这些图”的解决方案
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。