【问题标题】:Saving subplot as an image? how to do it将子图保存为图像?怎么做
【发布时间】:2019-12-05 09:26:27
【问题描述】:
def sample_stack(stack, rows=8, cols=8, start_with=1, show_every=1):
    fig,ax = plt.subplots(rows,cols,figsize=[12,12])
    for i in range(rows*cols):
        ind = start_with + i*show_every
        ax[int(i/rows),int(i % rows)].set_title('slice %d' % ind)
        ax[int(i/rows),int(i % rows)].imshow(stack[ind],cmap='gray')
        ax[int(i/rows),int(i % rows)].axis('off')
images = sample_stack(imgs_to_process)

运行后我不希望它显示,而是将图像放入文件夹中

【问题讨论】:

标签: python matplotlib


【解决方案1】:

只需使用 plt.savefig() 代替 plt.show():

plt.savefig(filepath)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多