Hover incorrect when supplying color as argument in add_trace
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the supplied R add_trace reproductions as the entry point, comparing p1 with p2 and checking the reported endpoint hover behavior. Done means the color-as-argument case no longer loses hover information for the first or last point, with the examples serving as a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100