Black Lives Matter. Please consider donating to Black Girls Code today.

Is there a way to display multiple images for comparison pusporse?

Hi everyone, I browsed through the documentation and tried google searched but have not yet found a way to display multiple images in the same plot like matplotlib. I would appreciate it if you can show me how. Thanks!

For example here’s the output from matplotlib:

Below is the code I used to generate the above plots

fig = plt.figure(figsize=(15,10))
ax = fig.add_subplot(1,2,1)
ax1 = fig.add_subplot(1,2,2)
ax1.set_title('Ground Truth')

Hi @tnguyen2921,

Yes, you can compare two images, including them in subplots:

from plotly.subplots import make_subplots
import plotly.graph_objects as go
from skimage import io
img = io.imread('')
fig = make_subplots(
    rows=1, cols=2)
fig.add_trace(go.Image(z=img), 1, 1)
fig.add_trace(go.Image(z=img), 1, 2)
1 Like

Thanks for your prompt reply. I’m using Jupyter Notebook and cannot reproduce the plots using your codes. Is there any additional set up I need to have for plotly to output figures in Jupyter Notebook?

I’m using Jupyter Notebook, too, and Plotly version 4.6.0.

You can also set the horizontal_spacing to display the images closer or shared_yaxes=True, to display yaxis ticks only for the leftmost image:

fig = make_subplots(rows=1, cols=2,

What error is displayed when you are running the above code?

1 Like

I think I figured out the problem. I needed to restart Jupyter Notebook as I downloaded the package when my notebook session was still on. Thank you very much for the help!