lundi 25 juillet 2016

Python and Matplotlib: Plot multiple graphs on the same figure fast

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
x = np.linspace(0, 2*np.pi, 1e5)
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 :(

Aucun commentaire:

Enregistrer un commentaire