I want to generate a large number (N
) of PDF plots using matpotlib
.
Each plot requires reading the contents of a variable x
without modifying it.
When N
is too large the code takes ages to finish.
Is it possible to speed things up using some flavor of concurrency
(e.g., by sending the job to generate each PDF to a different thread)?
from pylab import *
N = 1000
x = linspace(0,100,10001)
for n in range(N):
fig = figure()
plot(x,sin(x/(n+1)))
savefig(f'{n+1}.pdf')
close(fig)