I am plotting error function values for around 10000 iterations and plotting them takes a lot of time. I want to avoid for-loop if possible to plot all of them in one figure, but speed it up anyway.
import time
import matplotlib.pyplot as plt
a = time.time()
for one in range(len(data)):
plt.plot(data[one],"-o")
plt.show()
b = time.time()
print(b-a)
What I tried was timing for:
(plt.plot(data[one],"-o") for one in range(len(data)))
plt.show()
But it didn't show any plot. So my goal is to speed up the plotting and remove for-loop if it is the bottleneck.
data is
data = array([[ 0. , 0. , 0. , 0. , 0. ],
[-43.4, -18. , -10.5, -7.4, -5.7],
[ 25.7, 18.3, 13.8, 10.7, 8.6],
[-25. , -10. , -5.8, -4.2, -3.3],
[ 16.1, 11.5, 8.6, 6.5, 5.1],
[-16.2, -6.4, -3.8, -2.9, -2.4],
[ 9.6, 7.1, 5.2, 3.8, 2.9],
[ -9.1, -3.4, -2. , -1.6, -1.5],
[ 4.7, 3.9, 2.9, 2. , 1.4],
[ -4.5, -1.3, -0.7, -0.8, -0.8]])
If it matters, x axis can be taken as
n = [i for i in range(5)]