Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hover incorrect when supplying color as argument in add_trace #2374

Open
Noskario opened this issue Aug 5, 2024 · 0 comments
Open

Hover incorrect when supplying color as argument in add_trace #2374

Noskario opened this issue Aug 5, 2024 · 0 comments

Comments

@Noskario
Copy link

Noskario commented Aug 5, 2024

I tried to create complex plot using add_trace. However there is problem with the hover when supplying color as argument: In this case the first and last element of the trace has no hover, sometimes it is only the first or only the last:

p1 <- plot_ly() |> 
  add_trace(
    type = "scatter",
    mode = "markers",
    x = 1:3,
    y = 1,
    color = 1:3,
    marker = list(colorscale = list(list(0, "red"), list(1, "orange")))
  )
p1

It works fine with

p2 <- plot_ly() |> 
  add_trace(
    type = "scatter",
    mode = "markers",
    x = 1:3,
    y = 1,
    marker = list(color = 1:3, colorscale = list(list(0, "red"), list(1, "orange")))
  )
p2

When doing the equivalent thing in python with

from plotly import graph_objects as go
fig2 = go.Figure()
fig2.add_trace(
    go.Scatter(x=[1,2,3], y=[1,1,1], type="scatter", mode="markers", marker={"color":[1,2,3], "colorscale":[[0,"red"],[1,"orange"]]})
)
fig1 = go.Figure()
fig1.add_trace(
    go.Scatter(x=[1,2,3], y=[1,1,1], type="scatter", mode="markers", color=[1,2,3], marker={"colorscale":[[0,"red"],[1,"orange"]]})
)

you get an error instead of an incorrect graph, which is better, I would claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant