I'm gatecrashing the party as I have unfortunately missed most of the latest
conversation. I had a discussion with Ralf recently and we agree that the
current X11 graphics ought to be enough for illustrative purposes (it also works
in jfricas and one can - in principle - include the graphics with ease into the
notebook as described in the **deprecated** doc draft:
https://nilqed.github.io/jfricas.pip/sphinx/_build/html/usage.html#draw
Since "graphics" is not may favourite subject either, enthusiasm has to be
fueled. Nevertheless I have been trying out various approaches with the
objective of "publication quality figures" in mind. I'd summarize the current
situation as follows:
- X11 draw works fine (but some people find it ugly)
- Bill's gnuDraw (works, requires gnuplot)
- Martin's Scene Graph (works, sophisticated)
(
https://www.euclideanspace.com/prog/scratchpad/mycode/graph/index.htm)
- Sixel graphics (requires xterm or similar sixel capable terminal (few) +
non-X gnuplot. I like it.
Since (AFAIK) there is no graphics library for CL, I see no alternative other
than resorting to an external tool - nobody will write a lib from scratch ;)
There a hundreds (maybe exaggerated) of such plotting libraries written in JS,
Java, Python etc. and some few written in C/C++. To narrow down the search it
should be at least BSD licensed, mature and provide pub quality:
Asymptote is LGPL, so not first choice.
https://en.wikipedia.org/wiki/Asymptote_(vector_graphics_language)
PGF/Tikz is GPL or LaTeX PPL
https://en.wikipedia.org/wiki/PGF/TikZ
The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast
with PSTricks, the PGF/TikZ graphics themselves are described in a language that
resembles MetaPost. This would be my second choice.
GLE - my favourite, BSD with a QT frontend lic. LGPL
https://en.wikipedia.org/wiki/Graphics_Layout_Engine
GLE satisfies all requirements.
https://glx.sourceforge.io/
https://glx.sourceforge.io/examples/index.html
It's essentially a command line tool which can produce a lot of formats e.g.
EPS, PS, PDF, JPEG, and PNG. The frontend (QGLE) is relatively new, yet very
handy in that one can manipulate the sources on the fly with automated update of
what you see ...
kfp@euler:~$ gle --help
GLE version 4.2.5
Usage: gle [options] filename.gle
More information: gle -help
Options:
-help Shows help about command line options
-info Outputs software version, build date, GLE_TOP, GLE_BIN, etc.
-verbosity Sets the verbosity level of GLE console output
-device Selects output device(s)
-cairo Use cairo output device
-resolution Sets the resolution for bitmap and PDF output
-fullpage Selects full page output
-landscape Selects full page landscape output
-output Specifies the name of the output file
-nosave Don't write output file to disk (dry-run)
-preview Previews the output with QGLE
-version Selects a GLE version to run
-compatibility Selects a GLE compatibility mode
-calc Runs GLE in "calculator" mode
-catcsv Pretty print a CSV file to standard output
-tex Indicates that the script includes LaTeX expressions
-inc Creates an .inc file with LaTeX code
-texincprefix Adds the given subdirectory to the path in the .inc file
-mkinittex Creates "inittex.ini" from "init.tex"
-finddeps Automatically finds dependencies
-nocolor Forces grayscale output
-inverse Render black as white for using on dark backgrounds
-transparent Creates transparent output (with -d png)
-noctrl-d Excludes CTRL-D from the PostScript output
-nomaxpath Disables the upper-bound on the drawing path complexity
-noligatures Disable the use of ligatures for 'fl' and 'fi'
-gsoptions Specify additional options for GhostScript
-safemode Disables reading/writing to the file system
-allowread Allows reading from the given path
-allowwrite Allows writing to the given path
-keep Don't delete temporary files
Show expert options: -help expert
Give more help about a given option: -help option
---
For the sake of completeness I mention that we (Ralf and me) tried Gnuplot 5+
(
http://www.gnuplot.info/) - the new HTML canvas) and matplotlib
(
https://matplotlib.org/). The results can be seen in the attached
ipysh_and_mplot.html and in the **deprecated**
https://nilqed.github.io/jfricas.pip/sphinx/_build/html/gnuplot.html. These
seems to me, however, not a long-term perspective because dev/release cycles of
this packages are quite rapid, users have to know/learn special syntax and last
but not least it might depend on browser flavour and javascript libraries.
So, coming to an end, my suggestion is to build upon GLE by utilizing the Fricas
domains Plot and Plot3D. The idea is to create a graphic object (a Record in
SPAD) that may be manipulated (overwrite defaults) and displayed in QGLE,
Texmacs, Jupyter or finalized in one of the graphic formats (ps, png etc.).
Instead of tiresome explanations I have attached a demo_gle.tar.gz containing a
rudimentary prototype, albeit one has to install the prerequisites:
sudo apt install gle-graphics
sudo apt install ghostscript # for TeX text/titles, otherwise optional
# checks
apt list -a gle-graphics
gle-graphics/bionic,now 4.2.5-7 amd64 [installed]
apt list -a ghostscript
ghostscript/bionic 9.22~dfsg+1-0ubuntu1 amd64
# test
$ qgle
should open an window, and
$ gle --version
GLE version 4.2.5
Usage: gle [options] filename.gle
More information: gle -help
To run the demo, extract "demo_gle.tar.gz" into /tmp or wherever, start fricas and
)read demo_qgle
which compiles gle.spad and provides two functions, demo() and demo3d().
Starting with
demo()
a first QGLE windows should open. The show will proceed when closing one window
after another (by upper right [X]), about five times. This should give an
impression about the quality and the features of QGLE.
The same can be done with
demo3d() -- only 2 windows ;)
Another - more simple - approach could be to tune view2D.spad, view3D.spad and
draw.spad allowing (users choice) different frontends for the "draw" command. I
did this 5y ago (
https://github.com/nilqed/fricas_input/tree/master/spad/draw,
see the patches and drawfe.spad), the result of test_draw.input can be seen
here:
https://kfp.bitbucket.io/drawfe/ (just an example as gnuplot sixel
(gnuplot itself provides a huge amount of 'set terminal' options). I would not
pursue this; too little gain for my taste compared to the builtin graphics.
Now it's up to the community to set the agenda. If no one is interested, then we
should allow the topic to rest awhile. The inventive mind will hardly produce
graphics form within fricas anyway?
On 23.03.2021 21:23, Ralf Hemmecke wrote:
>> How easy would it be to try KaTeX?
https://katex.org/ Maybe someone
>> has already tried this?
It has actually improved since I tried some years ago (was not complete, but
fast). Using it in Jupyter might certainly be an option. At the moment, however,
MathJax is a dependency of Jupyter (installed with the core nb) and has some
advantages over KaTeX (AFAIK, might have changed) in that one can easily pick
the LaTeX source code by right clicking on the displayed formula. Moreover, I'm
quite sure that the speed of MathJax will improve in the near future (it's not
so bad at all).
> I cannot say. That is the first time I look at Katex. If it really
> renders faster that would be wonderful. But I wait until somebody throws
> a working .ipynb -> .html conversion at me that replaces mathjax with
> katex in the .html flle so that I would see how to actually use it.
>> It seems to me that Kurt has already experimented with several options
>> and that his opinion was that we should just pick one of these and run
>> with it.
>
> Yes, but I am not sure whether his stuff was already ripe for production.
You're right, far from production, however if there is a compass, I guess it
will be doable in reasonable time, but as I am more the 'prototyper' (I dread
the last mile) it won't go without your discipline and persistency :)
>
> Ralf
>