plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

View jumps when zooming line graph

Open mikypilota opened this issue 10 months ago • 3 comments

I am experiencing the same problem described in this issue for Plotly.js.

In my python implementation, the line graph is so configured:

{
    "xaxis": dict(
        gridcolor="rgba(128, 128, 128, 0.2)",
        zerolinecolor="rgba(128, 128, 128, 0.2)",
        showgrid=True,
        type="date",
        tickformatstops=(
            [dict(dtickrange=[None, None], value="%a %d %b %y - %H:%M")]
        ),
    ),
    "yaxis": dict(
        gridcolor="rgba(128, 128, 128, 0.2)",
        zerolinecolor="rgba(128, 128, 128, 0.2)",
        showgrid=True,
    ),
    "spikedistance": -1,
    "xaxis_showspikes": True,
    "yaxis_showspikes": True,
    "xaxis_spikemode": "across",
    "yaxis_spikemode": "across",
    "xaxis_spikecolor": "rgba(255,255,255,0.5)",
    "yaxis_spikecolor": "rgba(255,255,255,0.5)",
    "xaxis_spikethickness": 1,
    "yaxis_spikethickness": 1,
}

The problem seems to surface when the tick text is long enough and when zooming will cause the tick text to end up at a particular distance from the edge of the line graph. I notice it happens more often when the tick text overflows following a zoom and will be subsequently hidden.

The issue won't occur if I do:

tickformatstops=(
   [dict(dtickrange=[None, None], value="%H:%M")]`
),

Because the resulting tick text won't be long enough.

mikypilota avatar Mar 22 '25 10:03 mikypilota

For some severely screwed up reason, setting:

margin=dict(l=80, r=80, t=20, b=20),

Stops the jumping.

I needed to play with those numbers a bit, it will work only after a certain threshold (ie 50 was not enough for me).

mikypilota avatar Mar 22 '25 19:03 mikypilota

thanks for the bug report and the follow-up - I'm marking this as P2 because I suspect the fix will have to be made in the plotly.js issue. Thanks - @gvwilson

gvwilson avatar Mar 24 '25 15:03 gvwilson

@gvwilson You're most welcome. In fact, thank you.

mikypilota avatar Mar 24 '25 18:03 mikypilota