Skip to content

Jupyter lab: Subplots share axis are not working properly #2683

@antmoev

Description

@antmoev

Using Plotly.py version 4.8.2, Jupyterlab version 2.1.5, Chrome Version 84.0.4147.105 or Firefox version 79.0, on Ubuntu 20.04.

When I zoom with my mouse within a subplots, the other subplots do not follow.
Here's the original subplot:
brain_with_no_zoom
And when I mouse zoom on the middle plot:
brain_with_axial_zoom

And the axis zoom do not propagate to other subplots too.

Here's my code cleaned:

np.random.seed(1)
image_3D = np.random.randn(9,9,9)

def get_heatmap(array_2d, cmap):
    return go.Heatmap(z=array_2d, colorscale=cmap)

def display_images(image_3D, slice_index, title, color_map = "oryel"):
    """
    """
    _layout_options = dict(title=title, title_x=0.5, autosize=True)
    _subplot_options = dict(rows=1, 
                           cols=3, 
                           subplot_titles=("1", "2", "3"), 
                           shared_xaxes=True, 
                           shared_yaxes=True)
    
    image_1= np.take(image_3D, slice_index, 0)
    image_2 = np.take(image_3D, slice_index, 2)
    image_3 = np.take(image_3D, slice_index, 1)
    
    fig = make_subplots(**_subplot_options)
    fig.add_trace(get_heatmap(image_1, color_map), row = 1, col = 1)
    fig.add_trace(get_heatmap(image_2, color_map), row = 1, col = 2)
    fig.add_trace(get_heatmap(image_3, color_map), row = 1, col = 3)
    
    fig.update_layout(_layout_options)
    fig.show()
    
    
display_images(image_3D, 6, "random cube")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions