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

**URL:** <https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [September 17, 2018, 6:45am UTC](https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050 "2018-09-17T06:45:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinOtter](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@MartinOtter](https://discourse.julialang.org/u/MartinOtter)\
**Post date:** [September 17, 2018, 6:45am UTC](https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050/1 "2018-09-17T06:45:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 17, 2018, 10:16am UTC](https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050/2 "2018-09-17T10:16:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![edljk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/edljk/32/2429_2.png) [@edljk](https://discourse.julialang.org/u/edljk)\
**Post date:** [September 17, 2018, 11:23am UTC](https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050/3 "2018-09-17T11:23:03Z")

</div>

from the documentation:

```julia
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

```

---

<div class="post-metadata">

**Author:** ![MartinOtter](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@MartinOtter](https://discourse.julialang.org/u/MartinOtter)\
**Post date:** [September 18, 2018, 3:09pm UTC](https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050/4 "2018-09-18T15:09:46Z")

</div>

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

```julia
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

 ![makie-fig](https://global.discourse-cdn.com/julialang/original/3X/5/e/5ebe8cd32a0afb8e97ce74dcd5f19e743c8e2264.png)

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.

---

<div class="post-metadata">

**Author:** ![MartinOtter](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@MartinOtter](https://discourse.julialang.org/u/MartinOtter)\
**Post date:** [September 18, 2018, 3:18pm UTC](https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050/5 "2018-09-18T15:18:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 18, 2018, 3:26pm UTC](https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050/6 "2018-09-18T15:26:58Z")

</div>

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 😉

```nohighlight
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

```

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [September 18, 2018, 3:31pm UTC](https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050/7 "2018-09-18T15:31:08Z")

</div>

Actually, this also works:

```nohighlight
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)

```

---

<div class="post-metadata">

**Author:** ![MartinOtter](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@MartinOtter](https://discourse.julialang.org/u/MartinOtter)\
**Post date:** [September 18, 2018, 4:14pm UTC](https://discourse.julialang.org/t/makie-how-to-define-subscenes-and-or-different-plot-windows/15050/8 "2018-09-18T16:14:20Z")

</div>

> 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).
