JuliaPlots / PlotlyJS.jl

Julia library for plotting with plotly.js
Other
418 stars 77 forks source link

Name feature not working anymore #434

Closed jd-lara closed 2 years ago

jd-lara commented 2 years ago

Adding name to a scatter stopped working

MWE

julia> s = scatter(;x=1:5, y=[1, 6, 3, 6, 1],
                             mode="markers", name="Team A",
                             text=["A-1", "A-2", "A-3", "A-4", "A-5"],
                             marker_size=12)
scatter with fields marker, mode, name, text, type, x, and y

julia> plot(s)

julia> plot(s, Layout())

Results in

image
empet commented 2 years ago

It is not clear what you expect to be displayed relative to the trace name. If you define

Layout(width=600, height=450, showlegend=true)

then the trace name will be displayed in legend. When a plot has a single trace in its definition the trace name is not displayed on hover, because there is no reason for confusion. But if add two traces:

using PlotlyJS
s = scatter(;x=1:5, y=[1, 6, 3, 6, 1],
                             mode="markers", name="Team A",
                             text=["A-1", "A-2", "A-3", "A-4", "A-5"],
                             marker_size=12)

pl = Plot(s, Layout(width=600, height=400, showlegend=true))

addtraces!(pl, scatter(x=LinRange(1, 5, 7), y=rand(2:9, 7), mode="lines", 
           name="trace name"))
display(pl)

then their names are displayed both on legend and on hover: hover-line