# Start GLMakie visualization in previous position with previous size

**URL:** <https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132>\
**Category:** Visualization\
**Tags:** makie, glmakie\
**Created:** [February 6, 2023, 11:14am UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132 "2023-02-06T11:14:32Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [February 6, 2023, 11:14am UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/1 "2023-02-06T11:14:32Z")

</div>

Is there a way to control where will GLMakie position the freshly invoked visualization in my system ?  
Currently I am running Debian 11 and whenever I invoke GLMakie the visualization appears behind the current REPL terminal. Then I move it to another monitor in order to see it at the same time as my REPL is open. But the next time I plot something again it’s hidden behind the current terminal.

Is there a way to pop every new GLMakie visualization to a predefined position in my Operating System (optimally last position experienced). The same goes for the window size of GLMakie.

---

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [February 13, 2023, 9:33pm UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/2 "2023-02-13T21:33:57Z")

</div>

Have you tried the `focus_on_show` and `resolution` arguments to `GLMakie.Screen`?

```julia
using GLMakie
GLMakie.Screen(; resolution=(1000, 500), focus_on_show=true)

```

I’ve been wanting to figure out the other things you mention and I think I’ve got it:

```julia
s = GLMakie.Screen()
glw = s.glscreen
cursize = GLMakie.GLFW.GetWindowSize(glw)
GLMakie.GLFW.SetWindowSize(glw, 1000, 100)
# resize the window manually..
GLMakie.GLFW.SetWindowSize(glw, cursize...) # goes back

```

There’s a `GetWindowSize` and `SetWindowPos` that work the same. On MacOS at least, this position seems to be on the extended desktop when there are multiple monitors.

BTW I figured this stuff out by entering `GLMakie.GLFW.` and then tab-completing to discover what was there. I guess one should probably read the actual [docs](https://github.com/JuliaGL/GLFW.jl) but they largely point to the GLFW documentation.

---

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [February 14, 2023, 11:36am UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/3 "2023-02-14T11:36:52Z")

</div>

Could you also mention how to plot anything on a `Screen` ?

I 've never really learned how to handle all these internal like `Scene`, `Camera` and `Screen`. To my knowledge, there are also no updated tutorials how to do so.

Maybe a related issue:

> <https://github.com/MakieOrg/Makie.jl/issues/2640>
>
> The current implementation of specifying the monitor in GLMakie seems to be brok…en.
> This script is enough to get a stacktrace:
> \`\`\`julia
> using GLMakie
> 
> config = Makie.CURRENT\_DEFAULT\_THEME\[:GLMakie\]
> config\[:monitor\]\[\] = GLMakie.GLFW.GetPrimaryMonitor()
> 
> GLMakie.activate!(; config...)
> 
> f = Figure()
> \`\`\`
> \`\`\`julia
> ERROR: MethodError: no method matching SetWindowMonitor(::GLFW.Window, ::GLFW.Monitor)
> Closest candidates are:
> SetWindowMonitor(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at C:\\Users\\storm\\.julia\\packages\\GLFW\\BWxfF\\src\\glfw3.jl:609
> Stacktrace:
> \[1\] apply\_config!(screen::GLMakie.Screen{GLFW.Window}, config::GLMakie.ScreenConfig; visible::Bool, start\_renderloop::Bool)
> @ GLMakie C:\\Users\\storm\\.julia\\packages\\GLMakie\\6Blp9\\src\\screen.jl:317
> \[2\] GLMakie.Screen(scene::Scene, config::GLMakie.ScreenConfig; visible::Bool, start\_renderloop::Bool)    
> @ GLMakie C:\\Users\\storm\\.julia\\packages\\GLMakie\\6Blp9\\src\\screen.jl:384
> \[3\] GLMakie.Screen(scene::Scene, config::GLMakie.ScreenConfig)
> @ GLMakie C:\\Users\\storm\\.julia\\packages\\GLMakie\\6Blp9\\src\\screen.jl:382
> \[4\] getscreen(::Module, ::Scene; screen\_config::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
> @ Makie C:\\Users\\storm\\.julia\\packages\\Makie\\Za3LL\\src\\display.jl:335
> \[5\] getscreen
> @ C:\\Users\\storm\\.julia\\packages\\Makie\\Za3LL\\src\\display.jl:323 \[inlined\]
> \[6\] display(figlike::Figure; backend::Module, update::Bool, screen\_config::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
> @ Makie C:\\Users\\storm\\.julia\\packages\\Makie\\Za3LL\\src\\display.jl:147
> \[7\] display(figlike::Figure)
> @ Makie C:\\Users\\storm\\.julia\\packages\\Makie\\Za3LL\\src\\display.jl:132
> \[8\] #invokelatest#2
> @ .\\essentials.jl:729 \[inlined\]
> \[9\] invokelatest
> @ .\\essentials.jl:726 \[inlined\]
> \[10\] (::VSCodeServer.var"#66#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
> @ VSCodeServer c:\\Users\\storm\\.vscode\\extensions\\julialang.language-julia-1.38.2\\scripts\\packages\\VSCodeServer\\src\\eval.jl:199
> \[11\] withpath(f::VSCodeServer.var"#66#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
> @ VSCodeServer c:\\Users\\storm\\.vscode\\extensions\\julialang.language-julia-1.38.2\\scripts\\packages\\VSCodeServer\\src\\repl.jl:249
> \[12\] (::VSCodeServer.var"#65#69"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
> @ VSCodeServer c:\\Users\\storm\\.vscode\\extensions\\julialang.language-julia-1.38.2\\scripts\\packages\\VSCodeServer\\src\\eval.jl:155
> \[13\] hideprompt(f::VSCodeServer.var"#65#69"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
> @ VSCodeServer c:\\Users\\storm\\.vscode\\extensions\\julialang.language-julia-1.38.2\\scripts\\packages\\VSCodeServer\\src\\repl.jl:38
> \[14\] (::VSCodeServer.var"#64#68"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
> @ VSCodeServer c:\\Users\\storm\\.vscode\\extensions\\julialang.language-julia-1.38.2\\scripts\\packages\\VSCodeServer\\src\\eval.jl:126
> \[15\] with\_logstate(f::Function, logstate::Any)
> @ Base.CoreLogging .\\logging.jl:511
> \[16\] with\_logger
> @ .\\logging.jl:623 \[inlined\]
> \[17\] (::VSCodeServer.var"#63#67"{VSCodeServer.ReplRunCodeRequestParams})()
> @ VSCodeServer c:\\Users\\storm\\.vscode\\extensions\\julialang.language-julia-1.38.2\\scripts\\packages\\VSCodeServer\\src\\eval.jl:225
> \[18\] #invokelatest#2
> @ .\\essentials.jl:729 \[inlined\]
> \[19\] invokelatest(::Any)
> @ Base .\\essentials.jl:726
> \[20\] macro expansion
> @ c:\\Users\\storm\\.vscode\\extensions\\julialang.language-julia-1.38.2\\scripts\\packages\\VSCodeServer\\src\\eval.jl:34 \[inlined\]
> \[21\] (::VSCodeServer.var"#61#62")()
> @ VSCodeServer .\\task.jl:484
> \`\`\`
> The code responsible seems to be:
> https://github.com/MakieOrg/Makie.jl/blob/156e651ffd1b20eed3f511f925c1e8ac4eed1474/GLMakie/src/screen.jl#L319-L321
> The correct function call seems to need 7 args:
> \`SetWindowMonitor(window, monitor, xpos, ypos, width, height, refreshRate)\`
> https://www.glfw.org/docs/3.3/group\_\_window.html#ga81c76c418af80a1cce7055bccb0ae0a7

---

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [February 14, 2023, 2:20pm UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/4 "2023-02-14T14:20:51Z")

</div>

I’ve just been doing something like

```julia
using GLMakie
scr = GLMakie.Screen(; resolution=(1000, 500))
fig = Figure()
ax = Axis(fig[1,1])
ax2 = Axis(fig[2,1])
display(scr, fig)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/d/0d15a28a556e2a33bd0d2b52387ca9d4899ff6db.jpeg)

There’s a `Scene` tutorial: [Scene tutorial · Makie](https://docs.makie.org/stable/tutorials/scenes/)

---

<div class="post-metadata">

**Author:** ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Post date:** [February 14, 2023, 3:38pm UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/5 "2023-02-14T15:38:25Z")

</div>

> [@filchristou](#):
>
> Currently I am running Debian 11 and whenever I invoke GLMakie the visualization appears behind the current REPL terminal.

I think this stuff is usually controlled by your desktop environment or window manager, and not `Makie`.

Not sure if there are settings in GNOME. If there aren’t and you are runnig X11 you might be able to use [`xdotool`](https://github.com/jordansissel/xdotool) to hack this together yourself.

---

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [February 14, 2023, 6:17pm UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/6 "2023-02-14T18:17:34Z")

</div>

> [@airpmb](#):
>
> ```julia
> fig = Figure()
> ax = Axis(fig[1,1])
> ax2 = Axis(fig[2,1])
> display(scr, fig)
> 
> ```

that doesn’t work at all on my machine debian 11, julia 1.8.4 and

```julia
(othermonitorglmakie) pkg> st
Status `~/code/julia/othermonitorglmakie/Project.toml`
  [f7f18e0c] GLFW v3.4.1
  [e9467ef8] GLMakie v0.8.2
  [ee78f7c6] Makie v0.19.2

```

---

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [February 14, 2023, 6:30pm UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/7 "2023-02-14T18:30:11Z")

</div>

Hmm, do you get an error message or just nothing at all?

---

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [February 14, 2023, 7:12pm UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/8 "2023-02-14T19:12:19Z")

</div>

I get 2 figures and `display` doesn’t keep the initial resolution.

---

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [February 14, 2023, 7:48pm UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/9 "2023-02-14T19:48:24Z")

</div>

I think the 2 figures is from the implicit `display()` that happens at the REPL. Try adding `;` to suppress that or run from a script. As for the resolution, my bad – put the that argument on the `Figure` call, not `Screen` (or both – if you just display the `Screen` without a `Figure` then the window seems to use the resolution in the call to `Screen`).

So, at the REPL, try this:

```julia
using GLMakie
scr = GLMakie.Screen();
fig = Figure(resolution=(200, 500));
ax = Axis(fig[1,1]);
ax2 = Axis(fig[2,1]);
display(scr, fig)

```

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

---

<div class="post-metadata">

**Author:** ![Audrius-St](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/audrius-st/32/24175_2.png) [@Audrius-St](https://discourse.julialang.org/u/Audrius-St)\
**Post date:** [February 14, 2023, 8:48pm UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/10 "2023-02-14T20:48:15Z")

</div>

On my system  
Windows 11  
Julia 1.8.5

```julia
function primary_resolution()
    monitor = GLMakie.GLFW.GetPrimaryMonitor() 
    videomode = GLMakie.MonitorProperties(monitor).videomode 
    return (convert(Int64, videomode.width), convert(Int64, videomode.height)) 
end
. . . 

screen = GLMakie.Screen()
gl_screen = screen.glscreen
width, height = primary_resolution()
GLMakie.GLFW.SetWindowSize(gl_screen, width, height)
figure = Figure()
. . .
wait(display(screen, figure))

```

does not work.

The `Figure()` function appears to override the `GLMakie.GLFW.SetWindowSize()` function and the default figure window size is displayed.

`figure = Figure(resoluton = primary_resolution())`

is required.

I see you’ve addressed this issue above while I was typing.

Will try `GLMakie.GLFW.SetWindowPos()` to see if it is overridden by `Figure()` or not.

---

<div class="post-metadata">

**Author:** ![Audrius-St](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/audrius-st/32/24175_2.png) [@Audrius-St](https://discourse.julialang.org/u/Audrius-St)\
**Post date:** [February 15, 2023, 5:53am UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/11 "2023-02-15T05:53:25Z")

</div>

On the other hand,

```julia
function primary_resolution()
    monitor = GLMakie.GLFW.GetPrimaryMonitor() 
    videomode = GLMakie.MonitorProperties(monitor).videomode 
    return (convert(Int64, videomode.width), convert(Int64, videomode.height)) 
end
. . .

    screen = GLMakie.Screen()
    gl_screen = screen.glscreen
    GLMakie.GLFW.SetWindowPos(gl_screen, 0, 30)

    figure = Figure(resolution = primary_resolution())
    . . .
    wait(display(screen, figure))

```

does work. One can use this code fragment to set the position of the screen + display on the monitor.

---

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [February 15, 2023, 6:57am UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/12 "2023-02-15T06:57:39Z")

</div>

`primary_resolution()` returns the maximum resolution of the monitor. some times that’s fine but not always. This looks like it should be covered by `fullscreen = false` on Screen attributes but it is also not working for me.

Thanks for your help. My workflow ended up being something like this.  
First define following function:

```julia
function restartfig(s::GLMakie.Screen ;pos = (5400, 50), res = (1000, 500))
    GLMakie.GLFW.SetWindowPos(s.glscreen, pos...)
    fig = Figure(resolution = res)
    display(s, fig)
    return fig
end

```

Then on your REPL:

```julia
julia> screen = GLMakie.Screen(); # initiate just once a Screen

julia> fig = restartfig(screen); # get figure to plot on

julia> scatter(fig[1,1], [0,1,2,4], [0,1,2,4]) # do your thing
Makie.AxisPlot(Axis (1 plots), Scatter{Tuple{Vector{Point{2, Float32}}}})

julia> fig = restartfig(screen); # restart fig on screen and get new figure to plot on

julia> scatter(fig[1,1], [0,1,2,4,5,6,7], [0,1,2,4,5,6,7]) # do your thing Vol2 and keep on like that
Makie.AxisPlot(Axis (1 plots), Scatter{Tuple{Vector{Point{2, Float32}}}})

```

---

<div class="post-metadata">

**Author:** ![Audrius-St](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/audrius-st/32/24175_2.png) [@Audrius-St](https://discourse.julialang.org/u/Audrius-St)\
**Post date:** [February 15, 2023, 6:20pm UTC](https://discourse.julialang.org/t/start-glmakie-visualization-in-previous-position-with-previous-size/94132/13 "2023-02-15T18:20:32Z")

</div>

Thanks for your code examples.  
My next question was to be how to call `Figure()` repeatedly after a single call to `Screen()`, but you’ve addressed it with the code in your post. I adapted it for scripts run using VS Code.

In future version of GLMakie, it would be ideal if one could specify both the resolution - size to be displayed and the position on the monitor of the display in `Figure()`.
