Reputation: 2239
I've got this code in an Emacs orgmode file:
#+begin_src gnuplot :exports results :file images/sinecosine.png
reset
set terminal png size 360, 360 enhanced
# Line styles
set border linewidth 1
set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 1 # blue
set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 1 # red
# Legend
set key at 6.1,1.3
# Axes label
set xlabel 'x'
set ylabel 'y'
set xzeroaxis linetype 2 linewidth 1
set yzeroaxis linetype 2 linewidth 1
# Axis ranges
set xrange[-2*pi:2*pi]
set yrange[-1.5:1.5]
# Axis labels
set xtics ("-2{/Symbol P}" -2*pi, "-{/Symbol P}" -pi, 0, "{/Symbol P}" pi, "2{/Symbol P}" 2*pi)
set ytics 1
set tics scale 0.75
# Functions to plot
a = 0.9
f(x) = a * sin(x)
g(x) = a * cos(x)
# Plot
plot f(x) title 'sin(x)' with lines ls 1, \
g(x) notitle with lines ls 2
#+end_src
and it gives a gnuplot (3.7) without the proper pi symbol -- just like in this and this post. Yes, I can get the eps version of this to work, but not this png (or svg) version, which is needed for HTML export. Any new ideas?
Update
Here is the stand-alone code I've tried -- successfully:
reset
set encoding utf8
set terminal svg enhanced fname 'Times New Roman' rounded dashed standalone
set output "gp-test4-output.svg"
# Line styles
set border linewidth 1
set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 1 # blue
set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 1 # red
# Legend
set key at 6.1,1.3
# Axes label
set xlabel 'x'
set ylabel 'y'
set xzeroaxis linetype 2 linewidth 1
set yzeroaxis linetype 2 linewidth 1
# Axis ranges
set xrange[-2*pi:2*pi]
set yrange[-1.5:1.5]
# Axis labels
set xtics ("-2Π" -2*pi, "-Π" -pi, 0, "Π" pi, "2Π" 2*pi)
set ytics 1
set tics scale 0.75
# Functions to plot
a = 0.9
f(x) = a * sin(x)
g(x) = a * cos(x)
# Plot
plot f(x) title 'sin(x)' with lines ls 1, \
g(x) notitle with lines ls 2
I've swapped out the {/Symbol P}
for Π. From a terminal command line I've gotten it to work and produce just fine. The Ubuntu repo did install the latest-greatest gnuplot (gnuplot 5.2 patchlevel 6). So doing the experiment again, when I C-c C-c
in the org-mode codeblock I get
gnuplot-mode 0.7-beta (gnuplot 3.7) -- report bugs with "C-c C-u"
and the same error: junk instead of Π. (Not sure what the gnuplot 3.7 is about.) Running the codeblock above, BTW, starts a gnuplot REPL, and it says it's latest-greatest gnuplot. But when the stand-alone code above in Emacs (with gnuplot-mode) is called a la "send buffer to gnuplot" (the Emacs gnuplot REPL) it gives the error, BUT when I "send file to gnuplot", it produces the Π error-free. Totally bizarre, IMHO.
Here's my subscriptions:
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
which gives two offerings for gnuplot modes:
gnuplot 20141231.2137 available melpa drive gnuplot from within emacs
and then this:
gnuplot-mode 20171013.1616 installed Major mode for editing gnuplot scripts
So then I uninstalled Emacs gnuplot
(20141231.2137), then installed gnuplot-mode
(20171013.1616). This solved the gnuplot-run-buffer
problem, but the org-mode codeblock now gives this error:
executing Gnuplot code block...
org-babel-execute:gnuplot: Cannot open load file: No such file or directory, gnuplot
Searching customize
I only find four variables associated with gnuplot, one being Gnuplot Program, which I have as /usr/bin/gnuplot
. I'm on latest-greatest Emacs and org-mode in Ubuntu 19.04. How do I better tell org-babel where to find Gnuplot? I suspect this newer mode is not the intended partner for Emacs org-mode; however the older mode is not doing greek letters properly in org-mode.
Upvotes: 0
Views: 3699
Reputation: 15093
Retrieving the character "pi" from the Adobe Symbol font is something from the PostScript world, where separate fonts with special encodings were used to work around the 256-character limit inherent in PostScript font encodings.
SVG, on the other hand, is an XML variant. It uses unicode entry points and (usually) UTF-8 encoding to access them. "pi" in an SVG file is either the byte sequence 0xCF 0x80 (UTF-8 encoding) or the XML predefined entity π
.
gnuplot's "enhanced text" mode is not relevant here. I do not remember what limitations there might have been in gnuplot 3.7 that would affect passing either of these as normal text to the svg terminal. There are no such limitations in current gnuplot.
Upvotes: 1