
New Features in Gnuplot 5.4 - leephillips
https://lwn.net/SubscriberLink/826456/2ea90dd464e104d5/
======
gen220
Before I got accustomed to gnuplot, I was most familiar with d3. I spent a lot
of time prototyping different viz strategies for myself in d3. All I can say
is, I was blind and now I see.

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.

~~~
The_rationalist
What are the concrete advantages of gnuplot versus D3?

~~~
gen220
It depends on your use case. An obvious one is that gnuplot doesn’t require a
web browser and a JavaScript VM, but I acknowledge this is irrelevant to some
people.

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!

------
gjulianm
My biggest grip with Gnuplot was that the default style is pretty terrible.
For everyone looking to make graphs, two pieces of advice:

\- 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](https://github.com/Gnuplotting/gnuplot-palettes) , such as dark2 or
viridis.

~~~
leephillips
Good advice. Even better to use one of the vector outputs, such as SVG, when
you can.

------
michaelrpeskin
Love to see it still alive! Did my whole Physics PhD in high performance C and
FORTRAN with gnuplot for visuals and Perl to tie it all together.

~~~
olodus
When I did my master thesis we had to use servers we were not allowed to
install most things on. But awk and gnuplot was there. All we needed for some
great results. Thought of it as a hack in the beginning but in the end it
became our whole pipeline.

------
haolez
Gnuplot was my first experience dealing with an open source project when I was
starting my career. I went to their IRC channel and asked something related to
the GNU project. I was immediately scolded: "Gnuplot is not a GNU project!!"
:D

~~~
middleclick
During my teenage years when I first started C++ (thank you Accelerated C++),
I went to the ##c++ channel on Freenode and was immediately flamed for my
"weird" nick, to the point that the people didn't bother to answer my question
but instead went after me personally, just because I had picked a nick based
on leet speak. I won't deny that it left a very bad impression on me about the
open source community, especially as someone who was new to it.

------
jgehrcke
For us, gnuplot and xmgrace were two of the most important command line tools
during physics education, esp. in computational physics. Often piping freshly
simulated data right into one of both for quick visualization.

~~~
kergonath
I still use gnuplot for publication-quality graphs, when I can’t be arsed to
use R.

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.

------
ddavis
Gnuplot is really an awesome project. Though I don't use it all that much
anymore, it will always hold a special place in my computing heart. In an
undergrad physics lab it was my first experience with launching a program from
a shell-- and that sure sent me in the right direction. Thanks to all who have
contributed to the project.

------
hendry
Here's a video of how to use Gnuplot within a Jupyter Notebook:
[https://www.youtube.com/watch?v=BhmctDeRAl4](https://www.youtube.com/watch?v=BhmctDeRAl4)

Advantage is that it's a slightly better environment to iterate in.

------
W0lf
For a quick and dirty on the spot visualization for some data on the command
line, I'd like to plug the following:

    
    
        function plot() {
            { echo 'plot "-"' "$@"; cat; } | gnuplot -persist;
        }
    

For example:

    
    
        seq 100 | sed 's/.*/s(&)/' | bc -l | plot linecolor 2

~~~
p4l4g4
Nice! I like it when you can plug such programs in a pipeline.

Recently 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!

------
xvilka
Problem of Gnuplot is their weird license that hinders it's adoption as a
library.

------
ggm
The example spider plot is covid19 data. In 30 years time somebody will look
at gnuplot 10 and say "oh yea I remember that.."

~~~
coldtea
"... it was back when the population was 8 billion and lived in cities as
opposed to 1 billion scattered underground"

------
billfruit
From using gnuplot of a few versions ago for tasks involving rather many plot
generation, I felt that the gnuplot syntax and commands are rather unintutive
and hard to remember, perhaps in some way aesthetically jarring. Also the
interactive plots it generated was rather barebones.

Plotting from a pandas dataframe seems more convenient way than using gnuplot
presently.

~~~
smabie
Yeah, I agree. Though actually I like plotting from Julia the best. You see
software like gnuplot a lot: started its life just doing one thing and then
slowly growing. The end result is an unholy mess of a system. All things
eventually end of being Turing complete, so let's just eliminate the middle
man and use a programming language.

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.

~~~
cosmic_quanta
Tangentially related: I've been working on a plotting tool
([https://github.com/LaurentRDC/pandoc-
plot](https://github.com/LaurentRDC/pandoc-plot)) that supports many plotting
toolkits. I recently added support for Plots.jl. I can't believe how SLOW it
is to get from running a script to getting output. 10x slower than matplotlib,
100x slower than Gnuplot.

~~~
leephillips
The first time you plot using Plots.jl it will take a long time as it compiles
the package, and maybe even has to download things. But subsequent plots
should be fast. Unless each time you run the script you are starting over
again—but that's not the best way to use Julia.

------
samch93
Amazing project, but seriously why do people spend their time and energy to
implement 3d bar charts?

~~~
leephillips
I don’t know the story in this case, but, usually, when the gnuplot devs
implement a feature like this, it’s because people are asking for it.

------
mangecoeur
> GNUplot is language independent

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).

~~~
leephillips
When people say gnuplot (not GNUplot) is language independent, they mean it is
not tied to the language in which you are creating the data that you are
plotting (unlike a plotting library, such as Matplotlib). This means that when
you move your simulation from Python to Fortran or Julia or C, you can use all
of your gnuplot scripts unchanged. You don’t have to learn about a new
plotting package or library. And that’s _because_ it has its own scripting
language.

~~~
whyever
I still don't see how this is different from matplotlib. You can also move
your simulation to a different language and keep using matplotlib for
plotting, with it's own scripting language Python.

~~~
leephillips
I’ve used both Matplotlib and gnuplot extensively for visualizing the results
of simulations and other tasks. I’ll try to briefly explain why I say that the
gnuplot solution is portable while the Matplotlib solution is not.

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.

------
nullc
I really wish Fedora would stop stripping GNU Readline out of gnuplot, this
really lobotomizes its usability.

~~~
gwd
It sounds like gnuplot's license isn't GPL-compatible, so Fedora would be
violating the law to ship gnuplot with readline.

What you really mean is, "I wish gnuplot would change their license to be GPL-
compatible so they could legally use readline."

~~~
nullc
Maybe, there is a disagreement about the license interpretation. For decades
only debian adopted this view, and only in fairly recently (last two years?)
did fedora drop readline support.

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)

------
langitbiru
You know what? I couldn't help myself thinking: So this is the kind of the
article that can get you paid $300 (give or take).

LWN pays $300 for a well-written article:
[https://news.ycombinator.com/item?id=23920240](https://news.ycombinator.com/item?id=23920240)

------
RodgerTheGreat
can you change a plot's background color without jumping through polygon-
drawing hoops yet?

~~~
leephillips

         set term x11 background rgb "aquamarine"
    

(for example).

