Gnuplot notes

From Helpful
Jump to navigation Jump to search
This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

Basic gnuplot

Terminal drivers

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

The terminal driver is the thing that takes the gnuplot code and writes/shows output. (Named from the command being terminal)


Non-interactive drivers

dumb - ASCII plots yay:)
pdf (via libpdf)
pdfcairo
postscript
epslatex, pslatex, pstex
svg
emf
gif supports animation
jpeg
png (via libgd)
pngcairo

Interactive drivers:

x11
ggi
wxt (uses wxWidgets and Cairo)
windows
pm (OS/2)
aqua (OSX)


Notes:

  • each terminal driver can have additional options - sometimes rather significant.
For example, postscript is black and white by default, but can also generate colors.
  • For raster images, you probably want pngcairo.
PNG because it has fewer limitations than gif or jpg for images like this,
and cairo-based because it has antialiasing and looks less blocky (than basic png, which is based on gd)


TODO:

  • (verify) this list
  • add 'since version'

File-less operation

gnuplot

  • seems to understand when stdin is a pipe (and not a tty?(verify))
  • lets you insert data inline (alongside the commands) so you can avoid files
like:
plot '-' using 1:2
  1 2
  3 4 
  5 6
e
(or use datablocks)
this is still finicky - if you want it to behave like an easy CLI utility, look at things like eplot


  • can output the image the stdout - by not setting output

Security

This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.

When you want to expose gnuplot to, say, the web, there are two security issues:

  • The ability to read from files
  • the ability to pipe from given commands

Both are hard to effectively blacklist, without removing too much, or actually parsing most of gnuplot's syntax.


Note that:

  • Single and double quotes may imply files (mostly on plots), or just string escaping (as in many set commands)
  • while < and | are used for piping. (within quoted strings only?(verify))
  • Letting in ; or newline is probably a bad idea too.


Probably the easiest solution is to generate a template for each specific use, and insert sanitized data into them.

See also


Other ways of using gnuplot

  • eplot
CLI, makes it easier to pipe in data

Python:

  • from a script
if using bare gnuplot, inserting data this way is arguably simpler than trying to pipe it in


https://stackoverflow.com/questions/20295646/python-ascii-plots-in-terminal