xxxxxxxxxx
Copied to clipboard
plt.savefig('plot.png', dpi=300, bbox_inches='tight')
xxxxxxxxxx
# Basic syntax:
plt.savefig("/path/to/output/directory/figure.png")
# Example usage:
import matplotlib.pyplot as plt
plt.figure()
plt.plot(range(5))
plt.savefig("~/Documents/figure.png", dpi=300)
xxxxxxxxxx
from matplotlib import pyplot as plt
fig, ax = plt.subplots()
# Control figure size or aspect ratio
fig.set_size_inches([width_val, height_val])
# Formats can be saved in lossless .png and vector .svg
fig.savefig("fig_name.jpg", quality=50) # Avoid values above 90
# Control resolution rendering
fig.savefig("fig_name.png", dpi=300)
xxxxxxxxxx
from matplotlib import pyplot as plt
plt.savefig('foo.png')
plt.savefig('foo.pdf')
xxxxxxxxxx
plt.savefig('your_path/a/b/'+str(yname)+'_'+str(xname)+'_'+str(dimername), bbox_inches='tight', dpi=300 )
^this is your name abc_AC (varibales) ^ crop edges