PlotlyJS.jl icon indicating copy to clipboard operation
PlotlyJS.jl copied to clipboard

The Modebar button " Compare data on hover" not showing up

Open Fizmath opened this issue 3 years ago • 3 comments

Julia 1.6.3
PlotlyJS  0.18.8
Plots  1.22.4

Why the modebar button Compare data on hover is not available in PlotlyJS ?


using PlotlyJS

t = range(0, 2π, length = 100)

p1 = scatter(x=t, y=cos.(t))
p2 = scatter(x=t, y=sin.(t))
p3 = scatter(x=t, y=sin.(3*t))

plot([p1,p2,p3],
config=PlotConfig(
        displayModeBar=true, 
        modeBarButtonsToAdd=[
            "hoverCompareCartesian",
            "toggleSpikelines",
            "drawline" ]    ) )

Screenshot from 2021-10-13 23-41-23

It seems that the config does not trigger some of the widgets.

The feature by default is available in Plotly backends, compare :

using Plots
plotlyjs()

xs = range(0, 2π, length = 100)
data = [sin.(xs) cos.(xs) 2sin.(xs) 2cos.(xs)]

plot(xs,data)

Screenshot from 2021-10-13 23-42-02

This is an important feature. Please guide how to include it in PlotlyJS.

Fizmath avatar Oct 13 '21 21:10 Fizmath

For me, this feature is actually NOT working when using the package as backend to Plots either.

Thanks a ton for you help!

JakobAsslaender avatar Oct 21 '21 23:10 JakobAsslaender

When you use Layout instead of config it seems to work (but don't ask me why).

using PlotlyJS

t = range(0, 2π, length = 100)

p1 = scatter(x=t, y=cos.(t))
p2 = scatter(x=t, y=sin.(t))
p3 = scatter(x=t, y=sin.(3*t))

Plot(
    [p1,p2,p3],
    Layout(
        modebar_add=[
            # (still) doesn't work
            # this most likely is because this option doesn't exist in
            # the reference <https://plotly.com/javascript/reference/#layout-modebar-add>
            # "hoverCompareCartesian",
            # but instead this option works
            "hovercompare",
            "toggleSpikelines",
            "drawline",
        ]
    )
)

Mo-Gul avatar Feb 26 '22 07:02 Mo-Gul

Anyone any idea who to call this option from Plots.jl?

JakobAsslaender avatar Mar 27 '22 18:03 JakobAsslaender