plt.savefig() automatically detects the file extension of the specified output path, and generates the corresponding file format if it is supported. If no file extension is specified in the input, a PNG format file would be obtained as output with the default backend. This supports a number of image formats, including PNG, JPG, PDF, and PostScript:
import numpy as np
import matplotlib.pyplot as plt
y = np.linspace(1,2000)
x = 1.0/np.sin(y)
plt.plot(x,y,'green')
plt.xlim(-20,20)
plt.ylim(1000,2400)
plt.show()
plt.savefig('123')