Skip to content

如何在使用 matplotlib 显示或保存图像时,只保存图像内容而没有周围的坐标和空白? #15

@daa233

Description

@daa233

例如我们使用下面的代码保存图像:

import numpy as np
import matplotlib.pyplot as plt

a = np.arange(9).reshape(3, 3)
plt.imshow(a)
plt.savefig('orig.png')

这样保存的图像如下图所示:
orig

怎么才能去掉坐标并去除周围的空白区域呢?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions