Makie: How to define subscenes and/or different plot windows

Could someone give a hint how to define subscenes (to have several figures in one scene) or define several plot windows with Makie?

There are 2 subscene examples hidden in the image section:
http://makie.juliaplots.org/stable/examples-image.html
Multiple windows is almost implemented but had some opengl and interface problems…

from the documentation:

data = rand(100, 50)
p1 = heatmap(data, interpolate = true)
p2 = heatmap(data, interpolate = false)
scene = AbstractPlotting.vbox(p1, p2)
text!(campixel(p1), "Interpolate = true", position = widths(p1) .* Vec(0.5, 1), align = (:center, :top), raw = true)
text!(campixel(p2), "Interpolate = false", position = widths(p2) .* Vec(0.5, 1), align = (:center, :top), raw = true)
scene
1 Like

Thanks.
My intention is to place several line plots in one window and with your hints I managed. Example:

module TestMakie

using Makie

x=collect(0:0.01:10); y=sin.(x)

scene     = Scene(resolution=(1000,400))
subscene1 = Scene(scene, IRect(0,0,500,400))
subscene2 = Scene(scene, IRect(500,0,500,400))

lines!(subscene1, x, y)
lines!(subscene2, x, 2*y)

display(scene)

end

resulting in

This definition with Makie looks nice and very powerful.

It might be helpful for other users to add such an example to the Makie tutorial.

4 Likes

When resizing the window with the mouse, then the content of the window is not scaled with the window size. Is there an option that must be added to Scene(…), in order that such automatic re-scaling is performed?

Something like this should work, but I consider it as very ugly - it’s one of the main reasons I haven’t officially published Makie yet :wink:

using Makie
AbstractPlotting.set_theme!()
x = collect(0:0.01:10); y = sin.(x)

scene = Scene(resolution=(1000,400))
area1 = lift(pixelarea(scene)) do a
    IRect(0, 0, widths(a) ./ Vec(2, 1))
end
area2 = lift(pixelarea(scene)) do a
    w, h = widths(a) ./ Vec(2, 1)
    IRect(w, 0, w, h)
end
subscene1 = Scene(scene, area1)
subscene2 = Scene(scene, area2)

lines!(subscene1, x, y)
lines!(subscene2, x, 2*y)

display(scene)

foreach(pixelarea(scene)) do area
    center!(subscene1) # need to center scene for each resize
    center!(subscene2)
end

Actually, this also works:

using Makie
x = collect(0:0.01:10); y = sin.(x)

a = lines(x, y)
b = lines(x, 2*y)
scene = AbstractPlotting.vbox(a, b)
display(scene)

Actually, this also works: […]

Hm. I tried this on my Windows 7 machine. When I resize the window, then suddenly a huge amount of characters is printed to the DOS window in which Julia is running and can only be stopped by closing the DOS window.

Anyway, I am just waiting until Makie is officially released (using PyPlot as a “workaround”). I was just curious about the status and whether multiple figures in one window and multiple windows are supported (which is important for my applications).