# Using the GLMakie plotting backend

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

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

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

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

Yes.

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

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

I then create a Figure with

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

add stuff to the figureās axes, beginning with

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

and finally display.

``````display(screen,f)
``````

There could be an easier way, though.

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.

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

1 Like

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

1 Like

There was a change in the default behavior:

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

Duplicate questions: