I am trying to draw a grid in Seaborn from a column in a CSV file. If I just use a standard list, this code renders a grid of colors, as planned. However, once I integrate the CSV file I get this error:
File "seagrid.py", line 73, in <module>
plot.imshow(np.arange(row_size).reshape(1, row_size),
AttributeError: 'numpy.ndarray' object has no attribute 'imshow'
My code is:
rgb_colors = list(map(hex_to_rgb, HexCodes))
row_size = 5
rows = [rgb_colors[i:i + row_size] for i in range(0, len(rgb_colors), row_size)]
num_rows = len(rgb_colors) // row_size + 1
f, plots = plt.subplots(num_rows, 1, squeeze=False)
plt.subplots_adjust(hspace=0.0)
for i in range(num_rows):
plot = plots[i]
plot.imshow(np.arange(row_size).reshape(1, row_size),
cmap=mpl.colors.ListedColormap(rows[i]),
interpolation="nearest", aspect="auto")
plot.set_xticks(np.arange(row_size) - .5)
plot.set_yticks([-.5, .5])
plot.set_xticklabels([])
plot.set_yticklabels([])
plt.show()
the CSV file is called using:
data = read_csv("predictions.csv")
HexCodes = data['hexCodes'].tolist()
I've compared the printed list from the CSV with the printed hardcoded list and they appear identical. Is the problem that I am importing using Pandas?