plotting with Julia in Jupyter Hub (and its terminal)

Denis Cioffi
  • 16 Dec '21

Dear Dylan,

Starting with translating the Python "tutorial" notebook into a Julia-based notebook in the Jupyter Hub, I have been able to use Julia's "PyCall" package to implement the provided Python scripts, e.g., il = pyimport("illustris_python"), and create the first few plots using Julia's "GR" plotting backend. It worked, but it was quite slow, e.g., taking about 30 seconds for a plot that in the Python notebook took about 5 seconds. Furthermore, the Julia Jupyter notebooks were massive, at least 15 times as large as the Python version, of order 20 to 30 MB. For some reason, the graphs are taking up much space.

The third plot (the blue and red specific star formation rate versus galaxy stellar mass) eventually plotted but hung the notebook (memory issue?). My first thought was that I should compare with using matplotlib as the Julia plotting backend, but its dependencies are more complicated, I set it up poorly, and the above pyimport would not work.

After experiencing some difficulties in trying several different plotting backends in notebooks on my own old laptop, I thought that perhaps the notebook is the (Julia) plotting complication, and I can bypass it by plotting on the terminal directly in Julia. I did this first on my own computer with a simple line plot. I found that I like the Gaston backend, which is based on gnuplot and requires that gnuplot be in the python distribution (it currently is not in the Jupyter Hub terminal's python).

When I tried that same simple line plot via the GR backend on the Jupyter Hub terminal, however, it did not plot, with the following (start to the) error message:

  This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

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

  Aborted (core dumped)
  connect: Connection refused
  GKS: can't connect to GKS socket application

Is there something else I should be doing before trying to plot from Julia in the Jupyter Hub terminal? I there an adjustment on your end that can get it to work? Or should I try another work around? Happy Holidays, and many thanks!

-- Denis

Dylan Nelson
  • 1
  • 16 Dec '21

Just a few thoughts for now:

(1) A Julia version of the "illustris_python" scripts is in the works, perhaps this will be ready soon and be useful.

(2) If you need something like gnuplot, you can definitely install it. Just make sure to install anything locally (i.e. into the user home directory of /home/tnguser/). Only changes inside this directory are saved.

(3) The error about "no QT" when plotting from a terminal seems similar to the question of using matplotlib without a windows system. I would guess that in Julia you can similarly specify the "offscreen" backend (or something similar), whereby you would produce plots to PDF or PNG files and not to the screen.

Denis Cioffi
  • 16 Dec '21

Thanks, Dylan. I will keep playing. -- Denis

Denis Cioffi
  • 16 Dec '21

GR.inline("pdf") solves the terminal plotting/saving problem in gr; updated reference: https://github.com/JuliaPlots/Plots.jl/issues/1905

  • Page 1 of 1