from PIL import Image from PIL import ImageDraw x=[] for i in range(400): x.append(i+50) screen = (500,500) bgcolor=(255,0,0) filename = "p.png" img = Image.new('RGB', screen,bgcolor) dr = ImageDraw.Draw(img) for x1 in x: dr.rectangle(((x1,x1),(x1+1,x1+1)),fill= (0,0,255)) img.save(filename)