I want to save all the matplotlib figures into pdf format. I have tried this approach but getting a blank pdf every time as output. How can I fix this and what am I doing wrong here?
from matplotlib import pyplot as plt
x = [37, 78, 67, 31, 88, 35, 62, 51, 60, 53, 5, 33, 24, 77, 20, 72, 74, 53, 17, 43, 56, 18, 17, 15, 17]
y = [46, 40, 96, 19, 50, 46, 47, 70, 64, 62, 26, 98, 34, 49, 4, 34, 91, 24, 92, 74, 9, 66, 69, 89, 41]
fig = plt.figure(figsize=(6, 4))
plt.scatter(x, y, s=2, c='#6bb9e8', alpha=1.0)
plt.show()
plt.savefig("myPDF.pdf", format="pdf")