New Features in Gnuplot 5.4
lwn.net
lwn.net
If you get a rush from piping massive csv files into sed/awk/grep/tr/cut, then into wc/sqlite3/[etc], and are at all interested in plotting visuals of the results for yourself, please do yourself a favor and spend 30 minutes riding the learning curve of this wonderful program. IME, the docs are wonderful and kind to beginners who aren't afraid to cmd+f for the bits they're interested in.
After a couple hours of fiddling, you'll find getting a first stab at a graph faster in gnuplot than in excel. Then, you'll wonder about all that time you could have been saving your whole life. Like any other cli tool, its language takes a bit of grokking, but you can institutionalize your knowledge in scripts and carry them with you the rest of your life. Seriously, try it out.
gnuplot integrates seamlessly with a shell, so you can do all of your data transformation in awk/sed, and pipe the results into gnuplot. For d3, you’d need to load the data file, plot it, and then face the temptation of tweaking in JS vs tweaking the source data.
The first iteration of “I have a csv file” to “I have an interpretable graph” is very quick with gnuplot, which helps with prototyping and identifying systematic features of the data. You can squeeze d3 to get this, but you’d need to whip out a lot of boilerplate to get there. There are a bunch of frameworks built on d3 that promise this sort of experience, but if you want to end up with fine-grained control of the viz, you’ll need to drop down into d3 eventually.
You don’t have to know anything about HTML, the DOM or CSS to make a decent graph in gnuplot. Of course, if you’re skilled at these, you can make very nice interactive graphs in d3. Tangentially, I had a viz professor who would give any one who used interactivity to encode a dimension of information an immediate bias of -20%, because interactivity is more often a limiting element rather than a feature. :)
That being said if I wanted to build something productively interactive, I’d still reach for d3 over gnuplot.
Curious to hear others thoughts on your question, too!
- Use pngcairo, or pdfcairo or something like that. Nobody likes graphs without anti-aliasing.
- Use a nice color palette, from https://github.com/Gnuplotting/gnuplot-palettes , such as dark2 or viridis.
The license it's essentially a BSD with the (absurd) restriction that you can't distribute the "complete modified source code", whatever that means, but only patches. I wonder what's the motivation.
Distribution of software was different then.
It’s also still very useful to generate on-the-fly plots to help sifting through large numbers of datasets.
The last steps of my simulations is usually to generate a graph showing critical parameters to make sure it makes sense at a glance. Much easier than eyeballing number tables. Gnuplot is perfect for this: it is very fast and lightweight.
Advantage is that it's a slightly better environment to iterate in.
function plot() {
{ echo 'plot "-"' "$@"; cat; } | gnuplot -persist;
}
For example: seq 100 | sed 's/.*/s(&)/' | bc -l | plot linecolor 2Recently found out that you can use png:- as source or destination in any imagemagick command, to pipe images around! I find it really useful in combination with xclip, with -t to set the mime type. You can paste the result almost anywhere!
Plotting from a pandas dataframe seems more convenient way than using gnuplot presently.
Other examples of this are html/js, excel, vim, and bc.
A much better result can be achieved if you first design then language (or use an existing one) and just implement libraries to do what you want. A good example of this is Emacs.
Greenspun's tenth rule: Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.
Incidentally, I haven't encountered much gnuplot use nowadays. Maybe 10 years ago it was pretty popular in academia, but most have moved onto using Python and matplotlib for plotting, even if the models are written in something else. Matplotlib is truly terrible, but at least it comes with a sort of acceptable programming language.
when I run top on a login server on HPC systems, there's always a few gnuplots doing something.
> Matplotlib is truly terrible
If Matplotlib is now considered terrible, then at least it has advanced the standard expectation. When I started plotting stuff, choosing among plplot, plotutil, latex, gnuplot etc, Matplotlib was and remains a great choice. And it does what you prescribe:
> first design then language (or use an existing one) and just implement libraries to do what you want
Not really since it's dependent on its own scripting language. That's like saying Matplotlib is language independent, you just need to know its scripting language (Python).
You don’t get plots from Matplotlib just by using Python, nor even Python + numpy. You also have to learn the conventions of the Matplotlib library, including the horrendous mechanism for making and storing settings. This amounts to learning Matplotlib’s domain specific language, which is at least as onerous as learning gnuplot’s scripting language.
When you move your simulation project from Python to another language (and this is a common sequence, as people often prototype a calculation in Python but then want to make it bigger) you will be able to keep using your Matplotlib routines if your method was to store the simulation output in a file and, in a decoupled step, read and plot the file with a Python/Matplotlib program. This is a trivial form of portability that goes without saying. But you will have to maintain a Python + numpy + Matplotlib + [maybe more] ecosystem, with the Python world’s notoriously shifting set of dependencies. In contrast, gnuplot is a compiled, standalone program. There is no ecosystem to maintain.
If your plotting phase was not decoupled from the calculation, and you have plotting code in your simulation code to plot things on the fly, you have to start over. Obviously you can’t use this plotting code in your Fortran program. In contrast, gnuplot has universal interfaces through sockets, FIFOs, and files. You won’t have to touch the plotting code, just trivially rewrite the lines of code that, for example, open and talk through a socket.
What you really mean is, "I wish gnuplot would change their license to be GPL-compatible so they could legally use readline."
The alternative it uses is broken almost to the point of unsuitability (e.g. write any line long enough to wrap and try editing it)
LWN pays $300 for a well-written article: https://news.ycombinator.com/item?id=23920240
set term x11 background rgb "aquamarine"
(for example).