Plotly Subplot Zoom

Hi,

I’m using a library called pymzml that is built on plotly to plot mass spectrometry data. Works great but I have run into an issue where I can not zoom on subplots. Well, only one of the subplot will zoom. These subplots are related but independent, so it would be great to be able to show both on the same page and zoom independently on either. I have an html example I could upload…
Is this a known issue?

Best,
Matt

Hi @mattstorey,

It should be possible to zoom in for just about all of the plot types, including when they are used as subplots. But it’s also possible to disable zoom as well so it might be a matter of how the pymzml constructs the figure. Do you have access to the raw figure specification (either as a dict or as a plotly.graph_objs.Figure object)? If so we might be able to look at the specification to see what’s going on.

-Jon

Hi, Jon.

Thanks for looking into this.

trace = go.Scatter(
            {
                'x': x_values,
                'y': y_values,
                'xaxis': {
                    'range': mz_range,
                    'autorange':False,
                },
                'yaxis': {
                    'range': int_range,
                    'autorange':False,
                },
                'text': txt,
                'textfont': {
                    'family': 'Helvetica',
                    'size': 10,
                    'color': '#000000'
                },
                'textposition': 'top center',
                'visible': 'True',
                'marker': {
                    'size'  : 10,
                    'color' : 'rgba'+str((color[0], color[1], color[2], opacity)),
                },
                'mode': mode,
                'name': name,
                'line': {
                    'color': 'rgba'+str((color[0], color[1], color[2], opacity)),
                    'width': self.style_options['line.width'],
                    'shape': shape,
                    'dash'  : dash,
                },
                'fill': filling,
                'fillcolor': {
                    'color' : 'rgba' + str((color[0], color[1], color[2], opacity)),
                    'opacity' : opacity,
                },
                'opacity': opacity,
            }
        )

Would this be the figure specification you mentioned?

Can I send you a sample plot so you can get an idea of what behaviour is happening? It seem like the axis are ‘zooming’, but the trace does not.

Matt

Hi Matt,

Sure. You can save a plotly figure to a json file like this:

import plotly.io as pio
pio.write_json(fig, 'fig.json')

-Jon