How to do plotting on WSL (Windows Subsystem Linux)

I am using WSL with Julia which makes it more reproducible, but I can’t get plotting to work on WSL.

Does anyone have any tips? I can start the Jupyter notebook, but I am referring to plotting in REPL.

Plotting by connecting Juno to a remote terminal also might work, but I couldn’t get it working.

Hopefully by posting here, any solution found would be more googlable.

I found this useful guide for WSL here https://github.com/econtoolkit/tutorials/blob/master/julia/WSL.md but it doesn’t cover plotting.

2 Likes

Which package? What does “plotting not working” mean? You can’t save plots? You can’t display them interactively? Something else?

I think for displaying plots things are quite limited, I think the only option that might work is if the plot package just writes an HTML file and opens that. But anything more fancy, with a custom UI etc., won’t work because WSL doesn’t support software that shows a UI, as far as I know.

1 Like

I’m pretty sure you can pull off something just like:

after all, once the plot has been produced and qt5 takes over, it’s just a matter of X protocol.

I guess not so easy, even though xeyes works

I got something to work with VegaLite.jl and VS Code. Here is how:

  1. Installed VS Code on Windows, and then added the Julia and Remote - WSL extension to it.
  2. I made sure Julia is on the PATH in WSL.
  3. I type code from my ~ home directory in WSL. That starts the VS Code in Windows, connected to WSL.
  4. I go to extensions and make sure the Julia extension is installed on the remote system.
  5. I start a Julia REPL inside VS Code. This is running in WSL.
  6. I install VegaLite#master (probably also works with the currently tagged version), and then everything works. Plots show in the VS Code Julia plot pane.

My best guess is that this also works with other plotting packages.

2 Likes

Ok got it working on Win 10 Pro with WSL 1 (not 2) with Ubuntu WSL

Follow these steps

  1. Install qt5 with sudo apt-get install qt5-default
  2. Add a line: export DISPLAY=localhost:0.0 to ~/.bashrc . Either source ~/.bashrc or restart WSL for this to take effect
  3. Install VcXsrv. Please note that Xming didn’t work for me and only VcXsrv worked.
  4. Test it out using Plots; gr(); plot(1:3)

Yay!

PGFPlotsX works just fine.

1 Like

I think there is actually room for a nice little display package, say WebDisplay.jl. It could push a display onto the multimedia stack, start a web server and then show any plot that is pushed to that display in some web page. Essentially something like ElectronDisplay.jl, but for a remote scenario.

It might be useful for the WSL scenario, but also for a scenario with a headless remote server: one could SSH into the server, do some stuff interactively, and then browse to some URL on that server to look at the plots.

5 Likes