# Using the GLMakie plotting backend

**URL:** https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013
**Category:** New to Julia
**Tags:** plotting
**Created:** [June 7, 2023, 5:41pm UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013 "2023-06-07T17:41:36Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![KZ-Spectra](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@KZ-Spectra](https://discourse.julialang.org/u/KZ-Spectra)
#### Post date: [June 7, 2023, 5:41pm UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013/1 "2023-06-07T17:41:36Z")

</div>

I want to use `GLMakie` for 3D plotting, but when I try to do the plotting I get a static image not in a Makie window:

[https://i.imgur.com/R44xxJa.png](https://i.imgur.com/R44xxJa.png)

Earlier this morning it was working just fine, but I have since then upgraded to version 1.9. Why does the plotting seem to not use the GLMakie backend?

**MWE**

```julia
using GLMakie, DifferentialEquations, LinearAlgebra, SparseArrays
GLMakie.activate!()

N₁=31 # Number of waveguides / size of solution vector
γ=1 # Nonlinear term strength parameter
h=1 # Grid spacing 

centerGrid = (N₁-1)/2;
x = -centerGrid:centerGrid;

# Coefficient matrix of second-order centered-difference operator (δ²u)ₙ
M = spdiagm(-1 => fill(1,N₁-1), 0 => fill(-2,N₁), 1 => fill(1,N₁-1))
M[N₁,1] = 1; # Periodic boundary conditions
M[1,N₁] = 1;

# RHS of DNLS. The solution vector u is a N₁x1 complex vector
g₁(u,p,t) = 1*im*(-1*M*u - @.(γ*((abs(u))^2).*u) )

# Julia is explicitly typed (e.g, cannot have Ixnt and Complex in same array) and so we must convert the object containing the initial data to be complex
u0 = Complex.(sech.(x))

tspan = (0.0,200)
prob = ODEProblem(g₁,u0,tspan, [h])
sol = solve(prob, Tsit5(), reltol=1e-8, abstol=1e-8)

z= [abs(sol.u[i][j])^2 for j=1:N₁, i=1:size(sol)[2]] # |u|²
y = sol.t

fig = Figure()
p1 = surface(fig[1,1], x, y, z,axis=(type=Axis3, xlabel="Space", ylabel="Time", zlabel="|u|²"))
#xticks!(fig, -N₁:1:N₁)
p2 = contourf(fig[1,2], x, y, z, axis=(xlabel="Space", ylabel="Time"))

fig
#save("dnls_makie.png", fig)
#plt = plot(p1,p2,layout=(1,2), size=(1200,800))

```

> julia\> Makie.current\_backend()  
> GLMakie

---

<div class="post-metadata">

### Author: ![martin.d.maas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martin.d.maas/32/50964_2.png) [@martin.d.maas](https://discourse.julialang.org/u/martin.d.maas)
#### Post date: [June 7, 2023, 6:37pm UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013/2 "2023-06-07T18:37:48Z")

</div>

Are you using VSCode, and getting the static image in the display area there?

---

<div class="post-metadata">

### Author: ![KZ-Spectra](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@KZ-Spectra](https://discourse.julialang.org/u/KZ-Spectra)
#### Post date: [June 7, 2023, 6:37pm UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013/3 "2023-06-07T18:37:59Z")

</div>

Yes.

---

<div class="post-metadata">

### Author: ![martin.d.maas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martin.d.maas/32/50964_2.png) [@martin.d.maas](https://discourse.julialang.org/u/martin.d.maas)
#### Post date: [June 7, 2023, 6:39pm UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013/4 "2023-06-07T18:39:43Z")

</div>

I was just looking for my code. Then to create the standalone screen you should do:

```julia
screen = GLMakie.Screen(float=true)

```

---

<div class="post-metadata">

### Author: ![martin.d.maas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martin.d.maas/32/50964_2.png) [@martin.d.maas](https://discourse.julialang.org/u/martin.d.maas)
#### Post date: [June 7, 2023, 6:41pm UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013/5 "2023-06-07T18:41:30Z")

</div>

I then create a Figure with

```julia
f = Figure(backgroundcolor = RGBf(0.98, 0.98, 0.98), resolution = (400, 400))

```

add stuff to the figure’s axes, beginning with

```julia
ga = f[1, 1] = GridLayout()

```

and finally display.

```julia
display(screen,f)

```

There could be an easier way, though.

---

<div class="post-metadata">

### Author: ![KZ-Spectra](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@KZ-Spectra](https://discourse.julialang.org/u/KZ-Spectra)
#### Post date: [June 7, 2023, 6:46pm UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013/6 "2023-06-07T18:46:11Z")

</div>

> [@martin.d.maas](#):
>
> `f = Figure(backgroundcolor = RGBf(0.98, 0.98, 0.98), resolution = (400, 400))`

Thanks, I’ll try to use this and will update if I get it working. Strange though that earlier this morning it was the default that the Makie window appeared. I didn’t have to do any of this nonsense.

---

<div class="post-metadata">

### Author: ![KZ-Spectra](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@KZ-Spectra](https://discourse.julialang.org/u/KZ-Spectra)
#### Post date: [June 7, 2023, 7:04pm UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013/7 "2023-06-07T19:04:51Z")

</div>

I found an easier solution thanks to the Makie discord user “Julius”:

> try `display(fig)` or disabling the plot pane in VSCode, I’m not sure when it changed but I think currently the plot pane takes precendence

---

<div class="post-metadata">

### Author: ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)
#### Post date: [June 7, 2023, 8:29pm UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013/8 "2023-06-07T20:29:37Z")

</div>

play with `Makie.inline(true)` or `Makie.inline(false)`. its one or the other 😃

---

<div class="post-metadata">

### Author: ![garrek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrek/32/27937_2.png) [@garrek](https://discourse.julialang.org/u/garrek)
#### Post date: [June 9, 2023, 4:47am UTC](https://discourse.julialang.org/t/using-the-glmakie-plotting-backend/100013/9 "2023-06-09T04:47:57Z")

</div>

There was a change in the default behavior:

> <https://github.com/MakieOrg/Makie.jl/issues/2956#issuecomment-1549148770>
>
> In the most recent update (GLMakie 0.8.5 on Julia version 0.9.0) GLMakie no long…er opens a separate window when executing from a file in Visual Studio Code (Julia extension also on the latest version). Instead, plots open in a new tab in VS Code, like CairoMakie. I tested with a new environment with only GLMakie installed and generating a blank \`Figure()\`. I'm not sure if it's a Makie or VSC problem.

Use  
`GLMakie.activate!(inline=false)`, or the solution suggested by @lazarusA

Duplicate questions:

> [@GLMakie plotting in VSCode?](https://discourse.julialang.org/t/glmakie-plotting-in-vscode/100057):
>
> Hello, I just updated my project’s dependencies and suddenly GLMakie displays my interactive plots in VSCode’s plot pane. Both Makie and GLMakie are at the latest versions. Was there any change as to how VSCode or GLMakie treats GLMalkie Screens ?

> [@Inline plot not showing up Makie](https://discourse.julialang.org/t/inline-plot-not-showing-up-makie/100071/2):
>
> There was a change in the default behavior. You can make it open in a separate window by using: GLMakie.activate!(inline=false) See these other posts on the same topic:
