How do I tell owl which device to use for plplot?

Hi, I need help getting started with Owl. Any advice would be greatly appreciated!

I want to use owl generate a plot and write it to a png file on disk. I don’t want to use jupyter, and I am running on a server (Ubuntu 20.04) so no GUI. I installed owl and owl_plplot via opam. Here is my program:

open Owl
open Owl_plplot

let () =
  let file = "test.png" in
  let f x = Maths.sin x /. x in
  let h = Plot.create file in
  Plot.plot_fun ~h f 1. 15.;
  Plot.output h

and here is the output I am getting:

dune exec ./main.exe
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.



If I recall correctly, this happens when you run it without a screen (like in docker, in github actions, or if you don’t install lots of x11 stuff). I fixed it setting up an environment variable. The following should work

QT_QPA_PLATFORM=offscreen dune exec ./main.exe

That works, thanks so much!