I have 2 lists that contain RGB value to be used as images in matplotlib:
pred_rgb = [(58, 61, 55),
(199, 138, 127),
(176, 176, 176),
(128, 118, 0),
(71, 92, 24),
(58, 255, 0),
(69, 128, 0),
(59, 55, 61),
(61, 55, 61),
(127, 145, 199),
(0, 60, 128),
(2, 32, 163),
(128, 0, 69),
(61, 58, 55),
(176, 176, 176),
(11, 176, 117),
(76, 0, 128),
(163, 2, 2),
(58, 61, 55),
(11, 73, 176),
(255, 94, 0),
(92, 58, 24),
(92, 24, 50),
(0, 128, 68),
(0, 128, 87),
(92, 68, 24),
(81, 255, 0),
(252, 252, 252),
(117, 128, 0),
(252, 252, 252),
(59, 61, 55),
(11, 176, 111),
(92, 57, 24),
(0, 55, 128),
(122, 0, 128),
(252, 252, 252)]
real_rgb = [(61, 55, 55),
(127, 182, 199),
(176, 176, 176),
(128, 0, 0),
(92, 24, 73),
(235, 255, 0),
(128, 0, 0),
(61, 55, 55),
(61, 55, 55),
(127, 182, 199),
(128, 0, 0),
(44, 163, 2),
(128, 0, 0),
(61, 55, 55),
(176, 176, 176),
(176, 11, 70),
(128, 0, 0),
(44, 163, 2),
(61, 55, 55),
(176, 11, 70),
(235, 255, 0),
(92, 24, 73),
(92, 24, 73),
(128, 0, 0),
(128, 0, 0),
(92, 24, 73),
(235, 255, 0),
(252, 252, 252),
(128, 0, 0),
(252, 252, 252),
(61, 55, 55),
(176, 11, 70),
(92, 24, 73),
(128, 0, 0),
(128, 0, 0),
(252, 252, 252)]
I have successfully show the images using for loop in matplotlib like this:
# real color
for i in range(len(real_rgb)):
plt.figure()
plt.imshow([[real_rgb[i]]])
plt.show()
# pred color
for i in range(len(pred_rgb)):
plt.figure()
plt.imshow([[pred_rgb[i]]])
plt.show()
the example output of both are: pred_output:
real_output:
Because I need to compare the 2 plots I need to combine them to be a plot that contains pred_plot on the left and real_plot on the right, so I use the subplots in matplotlib with for loop... Here's the code:
data_num = 36
fig, axes = plt.subplots(nrows=data_num, ncols=2, sharex=True, sharey=True)
for n in range(data_num): #row index
for i in range(data_num):
plt.figure()
plt.imshow([[pred_rgb[i, 0]]])
plt.imshow([[real_rgb[i, 1]]])
plt.show()
I've run it and it gives an error like this

Does anyone know how to display 2 columns of subplots vertically/downward?



