I have about 50 000 columns I want to plot in the same figure. Here is the code I use:
# "Xaxis" is a list containing the x-axis, and "data" a list of the 50 000 data series I want to plot.
for elt in data:
plt.plot(Xaxis,elt)
This is a bit time consuming (I need to wait about 15min). Any suggestions to optimize the process/reduce the time ?
Thanks!
解决方案
One sentence answer: Use a LineCollection.
There are several options to draw many lines.
A. A loop
One can loop through the data and create one plot per line.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
def loop(N, show=False):
x = np.random.rand(N,3)
y = np.random.rand(N,3)
fig, ax = plt.subplots()
for i in r