# How can a cube/ a group of cubes be painted?

Setup : Blender 2.82

I want to achieve something similar to what was represented below but through a python script.

If each cube here represents a pixel, what is the fastest way to change its color so it looks exactly like the 2d image?

1. I wonder if it is possible to put there an actual RGB photo and not just a number?
2. I am also curios if i can map on a face of an cube a full image like a feature map from a tensorflow model ?

Here is the code that i have atm for creating cubes at different location in different collections

def createCubes(x,y,z, name):
collection = bpy.data.collections.new(name= name)
k = 0
l = 0
for i in range(0,int(z)):
for j in range(0, int(x)):
bpy.context.active_object.name = 'cube'
cube = bpy.context.object
for ob in cube.users_collection[:]: