Is there a faster way of plotting multiple curves over the same x range than the following?
import numpy as np
import matplotlib.pyplot as plt
N = 100 # trajectories
p = 1e3 # points
x = np.linspace(0, 2*np.pi, p)
y = [np.sin(x)**i for i in range(N)]
color = iter(plt.cm.rainbow(np.linspace(0, 1, N)))
[plt.plot(x, y[i], c=next(color)) for i in range(N)]
plt.show())
This code takes considerable time when plotting many trajectories (N~1e5)
x = np.linspace(0, 2*np.pi, 1e5)) seems a bit excessive. On my system 100 points per plot produces lines that are every bit as smooth as the ones with 10,000 points. (Without the slowdown that the large plots cause.)1e5points per line?