# 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: