matplotlib如何保存高分辨率图(亲测)

方法1:采用plt.subplots()这种形式

import matplotlib.pyplot as plt
 
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 5, 6])
fig.savefig("southeast_university.png", dpi=300)

方法二:采用plt形式

这里我直接写保持那句话了.说实话 一般300dpi已经很可以了。

plt.savefig("output.png", dpi=300)

例如:

import numpy as np
from matplotlib import pyplot as plt
x = np.linspace(-6, 6, 1024)
y = np.sinc(x)
plt.plot(x, y)
plt.savefig('southeast_university.png', dpi=300)

猜你喜欢

转载自blog.csdn.net/Vertira/article/details/133531819