# How to make GLMakie "open interactive windows" from Jupyter

**URL:** <https://discourse.julialang.org/t/how-to-make-glmakie-open-interactive-windows-from-jupyter/68299>\
**Category:** Visualization\
**Tags:** glmakie\
**Created:** [September 17, 2021, 2:42am UTC](https://discourse.julialang.org/t/how-to-make-glmakie-open-interactive-windows-from-jupyter/68299 "2021-09-17T02:42:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Post date:** [September 17, 2021, 2:42am UTC](https://discourse.julialang.org/t/how-to-make-glmakie-open-interactive-windows-from-jupyter/68299/1 "2021-09-17T02:42:49Z")

</div>

I am trying to reproduce a simple plot with a slider [from the Makie docs](https://makie.juliaplots.org/stable/examples/layoutables/intervalslider/#example_13269722351159645860).

I read in the Makie [basic tutorial](https://makie.juliaplots.org/stable/tutorials/basic-tutorial/)

> To see the output of plotting commands when using CairoMakie, we recommend you either use an IDE which supports png or svg output, such as VSCode, Atom/Juno, **Jupyter** , Pluto, etc.,

So I pasted the slider example code into a Jupyter notebook:

```julia
using CairoMakie

f = Figure()
Axis(f[1, 1], limits = (0, 1, 0, 1))

rs_h = IntervalSlider(f[2, 1], range = LinRange(0, 1, 1000),
    startvalues = (0.2, 0.8))
rs_v = IntervalSlider(f[1, 2], range = LinRange(0, 1, 1000),
    startvalues = (0.4, 0.9), horizontal = false)

labeltext1 = lift(rs_h.interval) do int
    string(round.(int, digits = 2))
end
Label(f[3, 1], labeltext1, tellwidth = false)
labeltext2 = lift(rs_v.interval) do int
    string(round.(int, digits = 2))
end
Label(f[1, 3], labeltext2,
    tellheight = false, rotation = pi/2)

points = rand(Point2f, 300)

# color points differently if they are within the two intervals
colors = lift(rs_h.interval, rs_v.interval) do h_int, v_int
    map(points) do p
        (h_int[1] < p[1] < h_int[2]) && (v_int[1] < p[2] < v_int[2])
    end
end

scatter!(points, color = colors, colormap = [:black, :orange], strokewidth = 0)

f

```

This causes the cell to output the following static image.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/f/bff7644d9116b511c6cfcaba0c179ff1b6f23a7f.png)

Needless to say, I want to be able to drag around the sliders. So, I went back to the [basic tutorial](https://makie.juliaplots.org/stable/tutorials/basic-tutorial/) (same link as above) and read the following:

> GLMakie can open interactive windows, or alternatively display bitmaps inline if `Makie.inline!(true)` is called.

I thought: “Aha, so if I use the GLMakie backend instead of CairoMakie, I can get Makie to open an interactive window! That’s what I need. Seems weird that the documentation slider example would use CairoMakie, but let’s try it.”

So, I changed the code above to the following:

```julia
using GLMakie
GLMakie.activate!()
Makie.inline!(false) # Probably unnecessary?

f = Figure()
# ...

```

but this produces the same, static figure as above, except with lower resolution:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/7/374a3fb62435345a27ab253e6e429eeaf5e5b7c2.png)

(The resolution is actually _quite bad_—look at the decimal point in `0.4`.)

Questions:

- How do I actually _get_ Makie to open the promised “interactive windows”?
- Can it be done in CairoMakie, or do I have to use GLMakie?
- If it’s the latter, then why does the slider example in the documentation use CairoMakie at all?

---

<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, 2021, 9:44am UTC](https://discourse.julialang.org/t/how-to-make-glmakie-open-interactive-windows-from-jupyter/68299/2 "2021-09-17T09:44:53Z")

</div>

- try display(f)
- no, you need to use GLMakie
- because it looks better, and won’t be interactive on the web anyways

---

<div class="post-metadata">

**Author:** ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Post date:** [September 18, 2021, 1:34am UTC](https://discourse.julialang.org/t/how-to-make-glmakie-open-interactive-windows-from-jupyter/68299/3 "2021-09-18T01:34:51Z")

</div>

For some reason on my Julia 1.6.1 installation I get `UndefVarError: Point2f not defined` using the script in the OP. This error goes away in Julia 1.6.2 or by changing `Point2f` to `Point2f0`.

> try display(f)

This works, thank you.

> because it looks better, and won’t be interactive on the web anyways

I’m not a developer, but isn’t this out of line with good documentation practice? It seems like a minimal requirement for example code in the documentation is that it actually _works_ as described, with aesthetic considerations secondary.

To someone new to Makie, the fact that one page says “CairoMakie doesn’t do interactivity” and then another page uses CairoMakie for an interactive plot is just confusing. The two pages contradict each other, and it’s not obvious which one is wrong.

---

<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 20, 2021, 7:33am UTC](https://discourse.julialang.org/t/how-to-make-glmakie-open-interactive-windows-from-jupyter/68299/4 "2021-09-20T07:33:22Z")

</div>

> To someone new to Makie, the fact that one page says “CairoMakie doesn’t do interactivity” and then another page uses CairoMakie for an interactive plot is just confusing. The two pages contradict each other, and it’s not obvious which one is wrong.

PRs to improve the documentation are very welcome 🙂
