gnuplot - pdf terminal - setting unicode character (solar mass symbol/odot)
Asked Answered
B

2

8

I'm trying to set the LaTeX \odot symbol in the gnuplot (4.6.0) pdf terminal. What is the exact syntax for this?

The gnuplot FAQ gives some clues, but should I type {/Symbol \2299}, or {/utf8 \2299}, or some other variation on \, /, # etc.? Or should I do set encoding utf8? Pasting the symbol in directly does not seem to work.

Should I use pdf or pdfcairo for the terminal? The latter affects my plots in intolerable ways.

Bronson answered 27/5, 2012 at 7:49 Comment(4)
Why cannot you just use $\odot$?Seaworthy
Because gnuplot's pdf terminal (as far as I know..) doesn't support LaTeX syntax.Bronson
do you need to use a pdf driver? You could use the latex terminal, w/ latex format for your figure and then use pdflatex to create your final figure...(there probably is an easier way -- You've just stumbled upon one corner of gnuplot I've never used before)Variolite
Also note that (depending on how precise you need it to be and your choice of font), you can use normal O overprinted with a '.' -- something like (with enhanced text turned on) ~O{.35.} might work (you may need to play around with the height (.35) to get it to look how you want it.)Variolite
I
3

It is pretty simple. First you need to select a terminal that supports Unicode; then you can indeed paste your Unicode characters in directly. The old pdf terminal does not support Unicode, as you've found out, but the more recent pdfcairo does. You say it messes up your graphs, but how? I've found that it produces the same result, but with better quality (smoother lines, antialiasing, and Unicode!).

Everyone has a different set of terminals installed. Other terminals that might support Unicode on your system are pngcairo and svg. The latter is a vector format, like pdf. If you need pdf as a final file and pdfcairo is not working for you, use something else that can handle Unicode and convert the file. The LaTeX solution is ultimately the best if you want excellent labels and mathematical adornments, but to control the output you will need to get good at LaTeX.

Insouciant answered 30/5, 2012 at 18:25 Comment(2)
Thanks @Lee that's exactly what I was looking for - it's helpful to know the standard PDF terminal isn't up to it. I agree pdfcairo looks better, but it does lead to problems; a main one is that the key is too large - how do I reduce the size of the key (reducing the font size doesn't reduce that of the lines, for example)?? I do quite like the epslatex route though - there's no issue with getting good at LaTeX ;)Bronson
There are many parameters you can set to adjust the size and spacing of the key; which one you need to tweak depends on just in what way the key is too large. I'm not sure, from your description so far, but I think you might want to try these: set key spacing x and set key samplen y, where you will try different numbers for x and y. For all the hairy details, type help set key at the gnuplot interactive plot (if you have the help system installed).Insouciant
M
5

Here is a way using the epslatex terminal. Run these commands in gnuplot or a gnuplot script:

set terminal epslatex standalone color
set output 'plot.tex'

set xlabel '$\odot$ is a \LaTeX symbol.'
plot sin(x)

Then you can run pdflatex on the resulting plot.tex, or latex followed by dvipdf. This works fine if you don't mind having LaTeX for the interpreter for all the text in your plot. If you want just the \odot symbol included I'm not sure how to do it.

Mcginley answered 27/5, 2012 at 13:46 Comment(4)
Thanks very much - this seems to be a v useful workaround. But it causes other problems, i.e. in this case the key is now too large (not just the font - the spacing of the lines). Do you have any ideas on how to reshrink it? Thanks again!Bronson
It can be tricky to adjust font sizes in LaTeX. You can try adding font X to the terminal specification line, where X is a font size. This way you can shrink the font across the board. Or you can increase the size of the canvas (e.g. adding size 10,6 at the terminal specification line), which will decrease the relative font size.Mcginley
Hi @Mcginley - how do I reduce the size of the lines in the key, rather than just the size of the accompanying text? Thanks!Bronson
I think @Variolite took care of that for you in a separate question.Mcginley
I
3

It is pretty simple. First you need to select a terminal that supports Unicode; then you can indeed paste your Unicode characters in directly. The old pdf terminal does not support Unicode, as you've found out, but the more recent pdfcairo does. You say it messes up your graphs, but how? I've found that it produces the same result, but with better quality (smoother lines, antialiasing, and Unicode!).

Everyone has a different set of terminals installed. Other terminals that might support Unicode on your system are pngcairo and svg. The latter is a vector format, like pdf. If you need pdf as a final file and pdfcairo is not working for you, use something else that can handle Unicode and convert the file. The LaTeX solution is ultimately the best if you want excellent labels and mathematical adornments, but to control the output you will need to get good at LaTeX.

Insouciant answered 30/5, 2012 at 18:25 Comment(2)
Thanks @Lee that's exactly what I was looking for - it's helpful to know the standard PDF terminal isn't up to it. I agree pdfcairo looks better, but it does lead to problems; a main one is that the key is too large - how do I reduce the size of the key (reducing the font size doesn't reduce that of the lines, for example)?? I do quite like the epslatex route though - there's no issue with getting good at LaTeX ;)Bronson
There are many parameters you can set to adjust the size and spacing of the key; which one you need to tweak depends on just in what way the key is too large. I'm not sure, from your description so far, but I think you might want to try these: set key spacing x and set key samplen y, where you will try different numbers for x and y. For all the hairy details, type help set key at the gnuplot interactive plot (if you have the help system installed).Insouciant

© 2022 - 2024 — McMap. All rights reserved.