I use qt
and wxt
terminals increasingly to quickly create plots, and export them directly to pdf or svg, as a convenient way to generate quality figures, rather than using cairolatex
and post-compilation by latex. The problem with this approach is that I can't easily typeset math labels properly, à la LaTeX. In fact, I use qt
/wxt
terminals for streaming data, so cairolatex
+ pdflatex
is too slow to work for dynamic display.
I have been playing with inserting latex labels using set pixmap 'xlabel.png' at graph 0.5,-0.1 center
, where xlabel.png
is a figure generated by pdflatexing a file like
\documentclass[12pt]{standalone}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\begin{document}
$\boldsymbol{\hat\alpha}_i$
\end{document}
and converting it to png using convert -density 200 -quality 85
(imagemagick) This works relatively well, but is hacky, and requires manual placement and adjustment of margins, rotation for y label etc. Some of it can be automated as we can call some of these 3rd-party utilities using <
in the filename argument of pixmap
.
But one of the main issue is that the size of the label image depends on pixel density and rescaling the label image in pixmap
with the height
or width
options scrambles it. The export from qt
as a pdf
is of poor quality.
The old ticket https://sourceforge.net/p/gnuplot/feature-requests/413/ would solve that issue, but I'd propose to go even further: it would be great if gnuplot could handle all (or most) of the intermediate steps: calling latex on the label text $\boldsymbol{\hat\alpha}_i$
, rotating, scaling, placing the label, adjusting margins so that we can have latex labels inserted in lots of terminals.
Being able to add latex labels elsewhere in the plot would also be useful (keys, anywhere really, just like pixmap
). These label images could be temporary images in /tmp
that only need to be recompiled if the labels have changed. It would add so much to be able to add LaTeX snippets to other terminals in a more convenient way than epslatex/cairolatex
, on the fly! :)
First thoughts:
I do not fully understand your workflow or your speed requirements, but let me suggest a possible alternative to your described use of qt or wxt followed by export to svg or pdf. Suppose you want to create a standalone pdf file with latex labels. I will use a plot of the complex Airy function from the gnuplot demo set as an example. The file
airy.gp
is here after some fiddling to change the label text to latex:gnuplot airy.gp
will produce an output fileairy.pdf
.okular airy.pdf&
.airy.gp
in the editor. Make your changes and - still from inside the editor - rerun gnuplot on the edited file.On my klunky old desktop machine at home it takes approximately 6 seconds from the time I invoke gnuplot the editor to the time that the display updates with the revised file. That's not instantaneous, but then again using the export widget to produce a separate file is not instantaneous either.
Last edit: Ethan Merritt 2023-07-16