Open nathansegers opened 4 years ago
I am also encountering this bug. I'm working with plotly in jupyter notebooks. It appears shapes are not rendered correctly in a plot with a categorical x-axis if the shape's x0 and/or x1 values are numeric category values.
Versions:
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
ipython : 7.25.0
Plotly : 5.1.0
Incorrect behavior example: Code:
import plotly.graph_objects as go
category_array = ["a1", "2", "3", "a9"]
trace = go.Scatter(
x=category_array,
y=[1, 2, 3, 4],
)
layout = go.Layout(
xaxis={
"type": "category",
"categoryarray": category_array
}
)
fig = go.Figure(
data=[trace],
layout=layout,
)
fig.add_shape(
{
"x0": category_array[1],
"x1": category_array[2],
"y0": 1,
"y1": 2,
}
)
display(fig)
Output:
Expected behavior example: (shape x0 and x1 values are non-numeric) Code:
import plotly.graph_objects as go
category_array = ["1", "a2", "a3", "9"]
trace = go.Scatter(
x=category_array,
y=[1, 2, 3, 4],
)
layout = go.Layout(
xaxis={
"type": "category",
"categoryarray": category_array
}
)
fig = go.Figure(
data=[trace],
layout=layout,
)
fig.add_shape(
{
"x0": category_array[1],
"x1": category_array[2],
"y0": 1,
"y1": 2,
}
)
display(fig)
Output:
Plotting lines in Plotly and JupyterDash gives a problem. I don't know if the issue is related to Plotly or JupyterDash, depending on which is the expected behaviour.
It did work in a previous version of Plotly.
Versions:
But apparently, this gives different results in Plotly as it does in Dash.
Plotly
Dash
(The small part on the left is the zoomed-out result, because the vertical-line was plotted at 31548 (which is the class of the X_data, but Dash seems to regard is as an integer) This only happened in the latest updates (I used to work with plotly=4.8.0 before this error)