I am trying to plot an image loaded in a pandas DataFrame. However, using px.imshow I get an empty plot only when using the values from pd.DataFrame.values even though using the same values as a numpy array works fine.
Here’s a code to reproduce the scenario:
color_matrix = [
[[255, 0, 0], [0, 255, 0],],
[[255, 0, 255], [255, 255, 0],],
]
img_rgb = np.array(color_matrix, dtype=np.uint8)
fig = px.imshow(img_rgb)
fig.update_xaxes(showticklabels=False).update_yaxes(showticklabels=False)
This code works successfully, but the following does not
img_rgb_df = pd.DataFrame(color_matrix)
img_rgb_df
fig = px.imshow(img_rgb_df.values)
fig.update_xaxes(showticklabels=False).update_yaxes(showticklabels=False)
What is the difference between the two values provided to px.imshow ?? and is that the reason the plot is empty ?
Many thanks