Skip to content

Unexpected behavior when changing a figure axis range #3040

@raphaeltimbo

Description

@raphaeltimbo

I have the following code:

import pandas as pd
import numpy as np
import plotly.express as px
import plotly.graph_objects as go

df = pd.DataFrame(
    {'CRL':
     {103: '5',
      104: '4',
      819: '3'},
 'TRL':
     {103: '6',
      104: '4',
      819: '2'},
 'COD_EV':
     {103: 'EV-00182',
      104: 'EV-00183',
      819: 'EV-01196'}
    }
)
g = [97, 181, 89, 0.5]
y = [255, 255, 100, 0.5]
r = [250, 112, 112, 0.5]

img_rgb = np.array(
    [
        [g, g, g, g, g, g, g, g, g, g],
        [g, r, r, r, g, y, y, y, y, y],
        [g, r, r, r, g, y, y, y, y, y],
        [g, r, r, r, g, y, y, y, y, y],
        [g, r, r, r, g, g, y, y, y, y],
        [g, r, r, r, r, g, y, y, y, y],
        [g, r, r, r, r, g, g, y, y, y],
        [g, r, r, r, r, r, g, g, y, y],
        [g, r, r, r, r, r, r, g, y, y],
        [g, r, r, r, r, r, r, g, g, g],
    ],
    dtype=np.float,
)

fig = px.strip(df, x="CRL", y="TRL", color="COD_EV")
fig.update_layout(
    xaxis=dict(
        showgrid=False,
        range=(0.5, 9.5),
        tickvals=[1, 2, 3, 4, 5, 6, 7, 8, 9],
        constrain="domain",
        title="CRL",
    ),
    yaxis=dict(
        showgrid=False,
        range=(0.5, 9.5),
        tickvals=[1, 2, 3, 4, 5, 6, 7, 8, 9],
        constrain="domain",
        title="TRL",
    ),
)

fig.update_traces(marker=dict(size=7), selector=dict(type="box"))
fig.add_traces(go.Image(z=img_rgb, colormodel="rgba"))
fig.update_traces(hovertemplate=None, hoverinfo="skip", selector=dict(type="image"))

Which would produce the following figure with plotly 4.12.0:
image

Now with plotly 4.14.3 I am getting this plot:
image

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