Test to generate 10 graphs (with randomly created colors) and plot them all on the same graph.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import math
def plot_large(*args, **kwargs):
fig = plt.figure()
fig.set_size_inches(14,8)
plt.plot(*args, **kwargs)
import random
def random_color():
""" Randomly generate colors in the form #aaccff. """
return '#' + ''.join([random.sample(list('abcdef'), 1)[0] for i in range(6)])
def flatten(lst):
return [item for sublist in lst for item in sublist]
# The domain
t = np.arange(0, 10, .1)
# Generate graphs for y = a*x (for x in range(10))
graphs = [[a * x for x in t] for a in range(10)]
# Generate [t, graph, color] triplets
graph_data = [[t, graph, random_color()] for graph in graphs]
# Flatten list of lists to pass to plot as *args
flattened_graph_data = flatten(graph_data)
plot_large(*flattened_graph_data)