Search code examples
juliamakie.jl

Does Makie have linked brushing capability similar to Holoviews?


In Holoviews it is possible to link two different plots, so that when we zoom in or select parts of one plot, the other plots reflects the same zooming in or selection. Are there similar functionality available in Makie?

Edit 1

Based on the answer I tried the code below, However, I get a static image. I tired it both in Jupyter lab notebook and VSCode both of which were installed in Windows Subsystem for Linux with Ubuntu. The code I tried is:

using CairoMakie

f = Figure(backgroundcolor = RGBf(0.98, 0.98, 0.98),
    resolution = (1000, 700)) 

ga = f[1, 1] = GridLayout()
gb = f[2, 1] = GridLayout()
gcd = f[1:2, 2] = GridLayout()
gc = gcd[1, 1] = GridLayout()
gd = gcd[2, 1] = GridLayout()

axtop = Axis(ga[1, 1])
axmain = Axis(ga[2, 1], xlabel = "before", ylabel = "after")
axright = Axis(ga[2, 2])

linkyaxes!(axmain, axright)
linkxaxes!(axmain, axtop)

labels = ["treatment", "placebo", "control"]
data = randn(3, 100, 2) .+ [1, 3, 5]

for (label, col) in zip(labels, eachslice(data, dims = 1))
    scatter!(axmain, col, label = label)
    density!(axtop, col[:, 1])
    density!(axright, col[:, 2], direction = :y)
end

f

Edit 2

After suggesting that I should use GLMakie for interactive plot, I tried it in VSCode and indeed I got an interactive plot. However, in Jupyter notebook, I got a static image. The solution is to use Makie.inline!(false) and display(f) rather than using f:

using GLMakie

Makie.inline!(false)

f = Figure(backgroundcolor = RGBf(0.98, 0.98, 0.98),
    resolution = (1000, 700)) 

ga = f[1, 1] = GridLayout()
gb = f[2, 1] = GridLayout()
gcd = f[1:2, 2] = GridLayout()
gc = gcd[1, 1] = GridLayout()
gd = gcd[2, 1] = GridLayout()

axtop = Axis(ga[1, 1])
axmain = Axis(ga[2, 1], xlabel = "before", ylabel = "after")
axright = Axis(ga[2, 2])

linkyaxes!(axmain, axright)
linkxaxes!(axmain, axtop)

labels = ["treatment", "placebo", "control"]
data = randn(3, 100, 2) .+ [1, 3, 5]

for (label, col) in zip(labels, eachslice(data, dims = 1))
    scatter!(axmain, col, label = label)
    density!(axtop, col[:, 1])
    density!(axright, col[:, 2], direction = :y)
end

display(f)

Solution

  • You can use linkxaxes! and linkyaxes!. Here's an example: https://makie.juliaplots.org/v0.17.13/tutorials/layout-tutorial/index.html#panel_a