1
$\begingroup$

I'm finding a quicker method to export plots

import numpy as np                                                      
from matplotlib.backends.backend_pdf import PdfPages 
import matplotlib.pyplot as plt

X = ... #define X
with PdfPages('MyFile.pdf') as export_pdf: 
   plt.figure() 
   plt.plot(np.arange(0,60+1), X) 
   plt.xlabel('t') 
   plt.ylabel('x(t)') 
   plt.title('title') 
   export_pdf.savefig() 
   plt.show() 
   plt.close()

I'm trying to find simpler code than the one I wrote attached. Any advice?

$\endgroup$
2
$\begingroup$
import matplotlib.pyplot as plt
import numpy as np
file = plt.figure()
plt.plot(np.arange(0,60+1), X)
plt.xlabel('t') 
plt.ylabel('x(t)') 
plt.title('title')
plt.show()
file.savefig("MyFile.pdf")
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.