You can create a suitable np.array
and fill the coordinates with the values from rgbArray
. Then plot the array with plt.imshow
. Missing coordinates will be plotted as black.
import numpy as np
import matplotlib.pyplot as plt
#Example with 3 coordinates in a 2x2 array
# [0,0] -> red
# [0,1] -> green
# [1,1] -> blue
# [1,0] -> 'no information'
coord = np.array([[0,0],[0,1],[1,1]])
rgb = np.array([[1.,0.,0.],[0.,1.,0.],[0.,0.,1.]])
img = np.zeros(tuple(coord.max(0)+1)+(3,))
img[coord[:,0],coord[:,1]] = rgb
plt.imshow(img)
plt.axis('off');
Out:
If you want a scatter plot there is no need to iterate over your arrays. You can use:
plt.scatter(coord[:,0],coord[:,1], color=rgb, s=20);
Out:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…