Perhaps you will first think about building an image on a bitmap that does not have a memory problem, and then fine-tune the graph / image using matplotlib. As an example:
from PIL import Image from PIL import ImageDraw import random import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mpimg s = (500,500) N = 100000 im = Image.new('RGBA', s, (255,255,255,255)) draw = ImageDraw.Draw(im) for i in range(N): x1 = random.random() * s[0] y1 = random.random() * s[1] x2 = random.random() * s[0] y2 = random.random() * s[1] c = random.random() * 256 draw.line(((x1,y1),(x2,y2)), fill=(0, 255 - int(c), int(c), 255), width=1) plt.imshow(np.asarray(im), extent=(-1,1,-1,1), aspect='equal', origin='lower') plt.show()
source share