Interactive plot, acting as a range slider tool for another plot?

I did this exact thing once. It can be done using VegaLite.jl

using DataFrames, VegaLite

function PlotWithFocus(A::DataFrame)
    A |> [
        @vlplot(mark={typ=:line,interpolate="linear"},x={field=:Time,typ=:quantitative,scale={domain={selection=:brush}},axis={title=""}}, y=:Displacement, width=600,height=400,title="Title",background="white");
        @vlplot(selection={brush={typ=:interval,encodings=["x"]}},mark={typ=:line,interpolate="linear"},x={field=:Time,typ=:quantitative}, y=:Displacement, width=600,height=80,background="white")
   ]
end

A=DataFrame(Time = collect(1:100),Displacement=[rand() for _ in 1:100])

PlotWithFocus(A)

Here I’ve used the same data for both but that wouldn’t be necessary.

5 Likes