gnuplot cannot set terminal to gif - gnuplot

I am trying to generate a GIF using gnuplot.
I downloaded and installed gnuplot version 5.0.6 from sourceforge, and am trying to run this example:
Creating gif animation using gnuplot
However I can't seem to be able to set terminal to gif, gif is not one of the available options under set terminal.
Has anyone encountered this, and figured out how to enable gif option in gnuplot?

Related

Gnuplot: gif unknown terminal

I am using Gnuplot v5.0 patchlevel 4.
I tried to use the gif terminal to make a gif animation see here. The problem is that I do not have the gif terminal among all the terminals. When I type set terminal gif animate delay 100 I received the error message: unknown or ambiguous terminal type. Here the list of my terminals
Subtopics available for set terminal:
cairolatex canvas cgm context
corel dumb dxf eepic
emf emtex epscairo epslatex
fig hpgl latex mf
mp pcl5 pdfcairo pngcairo
pop postscript pslatex pstex
pstricks push qms svg
tek40xx tek410x texdraw tgif
tkcanvas tpic vttek x11
xlib xterm
the tgif one is not working so, my question is, can I use/import in gnuplot a new terminal, such as the gif one ? Thanks

gnuplot gif not scalable with ttf font

After installing libgd on RedHat Linux, I found the path to .ttf fonts and used the full pathname to a DejaVu .ttf font (in 'set terminal gif font...") to create a .gif file from gnuplot. It looks good in a Firefox window, but when I change the size, it looks bad, as though the font is not scalable.
I am using the default binaries. Do I need to recompile gnuplot with different settings to make it scalable? I get no errors or msgs when the image is created from gnuplot (i.e. it finds and uses the .ttf file; I know because I tried several fonts and the image responded accordingly, with .pfa fonts also).
The gnuplot documentation says that TrueType fonts are fully scalable. Maybe I don't understand what scalable means. I had a similar problem with SUN OS, and my solution was to create a postscript (.eps) file from gnuplot and then convert it to .gif, and then it was scalable, but I don't have such a conversion utility on Linux (yet), and it seems like an unnecessary step.
I don't have the actual code/output in front of me, but I can add some if it would help. Also, I can't find any arial.ttf fonts on the system. Maybe that is a clue to the problem.
I heard good things about pngcairo (to avoid using gd), but 'set terminal' does not list it as an image type.
This is not a definitive answer, but it allows to show me a picture of the situation on my machine.
This plot was generated as gif using gnuplot 4.6p5 and Suse Linux 13.2.
The upper plot shows labels written in DejaVu, left using the full path to the TTF file, right using the name of the font. (DejaVu is an installed font here.)
The lower plot shows the same, the font is from the game Minecraft (i.e. very pixelated). I do not get any error message about missing fonts or similar, but gnuplot uses its default font here, but not what I want. More interesting: When I do not specify the font, I get Liberation Serif...
However, it seems my system ONLY uses fonts, regardless if referenced by name or path, when the font is correctly installed. Nevertheless, also the default font is smooth and scalable. (the gnuplot help says, gd has some not scalable build-in fonts, which may be used in your plot)

Gnuplot: is there a way to add small gif icon on the plot?

I am looking for a way to add small icons on the plot, like OK or KO symbols, flags, arrows and such.
So far I've seen an example where you can add a background image, but nothing that actually allow me to set a point on the plot, like I could do with a label, and apply there an icon.
Is there a way to do so?
Call me obsessive but as usual this can be done with the epslatex terminal, embedding the image using a set label statement as you would do in regular latex. If your image is so-icon.png, then within gnuplot do:
set terminal epslatex standalone header "\\usepackage{graphicx}"
set output "plot.tex"
set label at screen 0.5,0.5 '\includegraphics{so-icon.png}'
plot sin(x)
And now run pdflatex
pdflatex plot.tex
Your output will be named plot.pdf and look like this:
Change the positioning of the label (help set label for more info) to wherever you want. You can also use the formatting options of \includegraphics{}, for example \includegraphics[width=2cm]{} for a 2cm wide version of your image (sorry, I don't do inches!).
Note that if you want to embed PNG, JPEG, GIF, PDF and so on, the pdflatex command is required, you cannot use regular latex for those.

GNUplot add OSX system font to PDF output

I need to use a symbol font called Moon Fonts TTF in the PDF output from GNUplot. GNUplot finds it with no problem in the Aqua terminal.
I've tried:
set fontpath "/Users/house/Library/Fonts/MoonPhases.ttf"
and other add fontfile suggestions from the gnuplot help pages with no luck.
I have also tried a series of .ttf, .otf, postscript and unicode-mapped fonts with some support from a typography expert, with no luck at all: pdfcairo, postscript or epscairo cannot seem to find it.
GNUplot's 'show fontpath' gives:
system fontpath is "/System/Library/Fonts" "/Library/Fonts" "/Users/house/Library/Fonts"
and the fonts are there in one of those paths. I also tried placing them directly in GN's working directory.
If anyone has suggestions about how to make this work it would be much appreciated.
OSX Snow Leopard
GNUplot 4.6.2
You could first use the postscript eps terminal to plot, and then convert the eps to postscript using epstopdf which, at least on my system, embeds the needed fonts into the resulting pdf. If it doesn't you can try to force it by providing the ghostscript parameter directly.
To make your font visible for the postscript terminal, install it into your fontpath and then use
fc-cache -fv
to reload your font cache. The name of the font might vary, because for postscript you have to find the postscript name of the font:
fc-query /path/to/your/font/MoonPhases.ttf | grep postscript
For more examples of this, read this Blogpost:
Schriftarten über Umwege: Gnuplot unter Linux und Mac OS X
It is in german language, but google Translate should help.

output.png from gnuplot is not as good as the figure from prompt shell

I often plot graphs in gnuplot prompt shell, like this:
gunuplot> plot sin(x) with linespoints pointtype 3
and the figure showed up is great.
Today, I save the graph in a .png file, like this:
gnuplot> set term png
gnuplot> set output "output.png"
gunuplot> plot sin(x) with linespoints pointtype 3
Then, I open output.png with eog in Ubuntu, like this:
$ eog output.png
I found that, the output.png displayed in eog is not as good as the figure plotted in prompt shell.
Why is that? Do I need to adjust some settings before save the output.png?
PS
I found that a way around it, first,
set term postscript
set output "output.ps"
then in linux shell,
$ convert output.ps output.jpg
This way some sort of solve the my problem.
The source of your problems with the PNG quality is most likely the missing antialiasing in the png terminal of Gnuplot. Since you give no screenshots, I'm not sure what you mean when talking about bad linewidth, but here's how it looks for me (on MacOS). This screenshot shows the output of gnuplot's native aquaterm output:
If we create a png using set term png, the lines become "jumpy" and pixellated:
However, there is a version of the png terminal that uses the Cairo libs for rendering, and that makes the output far more smooth and nicer. set term pngcairo gives this result:
You can use set terminal to check whether this terminal version is available for you. If it is, this should save you conversion work and also give better image quality than a JPG (which is not an ideal format for line art).
The default size of the PNG image generated gnuplot with the PNG terminal is 640x480 pixels. This resolution in certain cases may result in "pixelated" graphs which are not as nice as those produced on screen with the default (wxt) terminal.
You can change the resolution of the output image using the size option:
set terminal png size <x,y>
where x and y are the desired numbers of pixels along the horizontal and vertical axis, respectively.
For example:
set terminal png size 1024,768
Please note that, images with larger resolution will result in proportionally larger files on disk. Alternatively you can try to use non-raster terminals like "post eps" or "pdf" if available on your machine, which may give you high quality scalable and (relatively) portable images without a large disk footprint.
Alternatively, if you want professional (publication-ready) quality images with gnuplot, you should have a look at the epslatex terminal. I have used it extensively for my thesis and my papers with very nice results, virtually no pixelation problems, portability when converting images to pdf, and almost all the capabilities of Latex.

Resources