How matplotlib saves high-resolution images (personal test)

Method 1: Use the form of 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)

Method 2: Use plt form

Here I just write the sentence "Keep". To be honest, generally 300dpi is enough.

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

For example:

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)

Guess you like

Origin blog.csdn.net/Vertira/article/details/133531819