✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Synchronizing view/zoom of several images

Hi all
For image analysis purposes (e.g., multi-image comparison), is it possible to synchronize Image/Heatmap views (pan, zoom) while maintaining axes aspect ratio of 1 (square pixels)?
Synchronizing (matching axes) is great and works perfectly accross Plotly subplots, but I found that the x-y scaleratio of traces then no longer remains 1, which is undesirable for images.

According to this post,

Synchronizing the subplots when zooming, panning etc. […] is not compatible with constraining axes aspect ratio

Would there be a workaround in dash like described here?
Thanks
.

Unfortunately, synchronizing subplot cannot actually be achieved while maintaining aspect ratio.
Quoting the doc:

Note that setting axes simultaneously in both a scaleanchor and a matches constraint is currently forbidden.

Hopefully this will be allowed in a future release.
Workarounds are possible in Dash or maybe a notebook (via IPython widgets), but at the price of manual range management in callbacks. Here is an extract of a Dash callback function with parameter data:

        if 'xaxis.range[0]' in data:
            xrange = [data['xaxis.range[0]'], data['xaxis.range[1]']]
            yrange = [data['yaxis.range[0]'], data['yaxis.range[1]']]
            fig.update_layout(xaxis_autorange=False, yaxis_autorange=False, xaxis_range=xrange, yaxis_range=yrange)
        if 'xaxis.autorange' in data:  # Autoscale : reset axes autorange
            fig.update_layout(xaxis_autorange=data['xaxis.autorange'])

Hi @olivl welcome to the forum! I would be very interested in this feature too for image processing :-). There is an open issue in plotly.js about this feature, you can subscribe to it to get notified about further progress. In the meantime, you can set the geometry of the subplots domain so that they correspond to the dimensions of your images but of course this is not a great solution (does not allow resizing the figure div).

Thanks for all @Emmanuelle. I have subscribed to the issue, looking forward to hear from.