Hi;
I have an issue when Iβm displaying a grey scale image in a subplot. Some images come out upside like this:
I created a checkbox to flip the image, but when I do, it also flips the histogram like this:
Does anyone know how to set it so that the histogram y-axis stays fixed, and only the image y-axis changes?
Here is the code Iβm using in the callback to display these images:
@widgets.interact(
imageIndex = imageSelector_dropDown,
enableAutoRange = autoRange_checkbox
)
def inspectImageArray(imageIndex, enableAutoRange):
# Create a figure object to hold subplots
fig = go.Figure().set_subplots(
rows = 1,
cols = 2,
horizontal_spacing = 0.1
)
# A plotly heatmap is used to display greyscale images
fig.add_trace(
go.Heatmap(
z = image_list[imageIndex],
colorscale = "gray",
reversescale = False,
),
row = 1,
col = 1
);
# Use the checkbox to flip the image
# if upside down
if enableAutoRange == True:
fig.update_yaxes(
autorange = "reversed"
);
# Create a histogram of pixel values
fig.add_trace(
go.Histogram(
x = image_list[imageIndex].ravel(),
xbins = dict(
start = 0,
end = 255,
size = 1
),
marker_color = 'black',
),
row = 1,
col = 2
);
# Updates the displayed size of the image
fig.update_layout(height = 500, width = 1100);
fig.update_xaxes(matches = None, showticklabels = True)
fig.update_yaxes(matches = None, showticklabels = True)
# Display the image
fig.show()
Can anyone suggest how I could do this? The only other option that I can think of is reversing the order of the numpy array before itβs read by the histogram?
Thank you!