jupyter kernel graphic output?

32 views
Skip to first unread message

David Woods

unread,
Jun 10, 2020, 7:42:52 PM6/10/20
to yacas
Is it possible to output Graph, Plot3DS, etc. to png without a GUI or Qt/X Windows? I have the jupyter kernel working for textual/LaTeX output, but graphical commands cause an error message in stdout "no X display found". 

I've run into a similar issue with other kernels like GDL, but found settings for adjusting output. Is output configurable in Yacas?

I'm building a docker image with several jupyter lab kernels, but because it's docker I'm avoiding X11 or other display mechanism. I have other kernels showing GnuPlot output with no problem. (These kernels will output a png to a tmp file, which is then deconstructed to a bytearray and delivered to the front end in a json string.)

Possible? I'm hoping I'm just missing a configuration or build option.

Grzegorz Mazur

unread,
Jun 14, 2020, 4:41:19 PM6/14/20
to yacas
Hi,

Unfortunately, the bad news is that it's not implemented. The good news it's that probably not that much work. Output is configurable in yacas, the mechanism is used in yacas-gui to just pass the numerical output from yacas and it's the gui part which creates the plot. Long time ago when I was writing the kernel it was more kind of proof of concept, and I skipped plotting at that time, either because the mechanism in jupyter was not yet completely clear or I just didn't have enough time. Anyway, I've looked at how it's done in other kernels, and the approach you've mentioned seems to be quite common. And it's a reasonable one. I'll try to come up with something soon, hopefully in a week or two.

Cheers,
Grzesiek

David Woods

unread,
Jun 14, 2020, 8:05:21 PM6/14/20
to yacas
That's terrific, I'm glad to hear it's feasible. I'll keep an eye out for updates!

Grzegorz Mazur

unread,
Jun 25, 2020, 12:39:57 PM6/25/20
to yacas
Hi,

I've just committed to the master branch something which seems to work: https://github.com/grzegorzmazur/yacas/commit/6cb0e40655790d5ca368b4535ac7e9879062fff6

I'd be grateful if you could check if it works for you.

Cheers,
Grzeiek

David Woods

unread,
Jun 25, 2020, 10:24:46 PM6/25/20
to yacas
Thank you Grzeiek, this works as expected! I was unable to build the yacas_kernel project, but I saw that yacas master was updated as well, which I can build without issue. A pull from master, rebuild and install, and it just worked.

2020-06-25 22_21_04-Coronavirus United States - live map tracker from Microsoft Bing.png

cheers!
david

Grzegorz Mazur

unread,
Jun 26, 2020, 4:12:28 AM6/26/20
to yacas
Hi,

Cool :) And yes, this is something I've got to finally clean up, all the various parts of yacas, like kernel or gui, which started as separate projects, got integrated into yacas and the old original projects should be simply removed to avoid misunderstanding.

BTW, in yacas-gui I generate the plots not as images but as JavaScript objects - this is better because you can eg zoom in, or, in case of 3d plots, manipulate the orientation. Are you aware of any kind of documentation on how something like that can be generated in jupyter? I think it is doable, at least the python kernel seems to able to generate a variety of interactive objects, but I haven't been able to find any documentation on how to actually do that.

Cheers,
Grzesiek

David Woods

unread,
Jun 26, 2020, 2:22:12 PM6/26/20
to yacas
No documentation that I know of, except very general info on Models and that I know the JS charts are based on a combination of kernel and extensions (nbextensions or labextensions - I use labs). I've seen some impressive interactive charts in some kernels (the BeakerX suite has some impressive interactivity), most appear to center around either Plot.ly or Matplotlib. My labextensions list includes jupyter-matplotlib, jupyterlab-plotly, and plotlywidget. (as well as jupyterlab_requirejs which might be used for obtaining the libraries, I'm not sure on that though)

I haven't seen anything similar with GnuPlot in JS format, so the first challenge would be building an extension. I'd imagine it wouldn't be too different than the plotly ones and focus mostly on pulling in the libraries and passing the data. In the Yacas kernel the last step would be building the JSON object defining the data that the gnuplot js would build the chart from, and embed it in the data.model payload of the websocket reply.

good luck!
-david

Reply all
Reply to author
Forward
0 new messages