[ANN]: Gnuplot v1.1.0 - A Julia interface to gnuplot

I’m glad to announce the first production ready version of Gnuplot.jl, a package to drive an external gnuplot process from Julia.

The most characterizing features of Gnuplot.jl are:

  • a carefully designed syntax, aimed to be extremely concise yet meaningful;
  • a very easy to learn API: just two macros (@gp and @gsp), accepting any number of arguments (either Julia numeric arrays, or gnuplot commands as strings), allow to produce the vast majority of plots;
  • possibility to export both data and commands into an external script, to be loaded directly in gnuplot (Julia is no longer required) to recreate exactly the same plot.

The above features makes Gnuplot.jl the ideal tool for interactive data exploration, and the script output allows easy decoupling of plot data and aethetics from the Julia code used to generate them. Other features are:

  • availability of all palettes from ColorSchemes;
  • support for multiple plots in one window, multiple plotting windows, as well as ASCII and Sixel plots (to directly plot in a terminal window);
  • support for histograms (both 1D and 2D);
  • enhanced support for contour plots;
  • export to a huge number of formats such as pdf, png, gif, LaTeX, svg, etc. (actually all those supported by gnuplot) to produce publication-quality plots.

The purpose of Gnuplot.jl is very similar to Gaston but the approach is rather different, with the former focusing mainly on syntax conciseness, a very simple API, and the scripting capabilities. On the other hand, Gnuplot.jl requires (and aims to value) some previous knowledge of gnuplot (which is not necessary to use Gaston).

The package comes with thorough documentation and a very extensive gallery of examples (thanks @lazarusA!).

Comments / issues are welcome!

61 Likes

Great! Nicely done!

2 Likes

I have to say I like that one essentially uses Gnuplot from Julia. So if I know Gnuplot, there is no need to learn an additional UI to use this. I simply write Gnuplot commands in Julia! Brilliant!

8 Likes

Indeed, although I think that it needs to be stress out that you don’t need to know gnuplot in order to use it. The basic syntax is so simple that anyone can use it, and then go from there.

3 Likes

Maybe this should be mentioned in the Readme. I was wondering about the strange macro-based UI.

1 Like

Like this in the documentation: (Home · Gnuplot.jl)

  • no need to learn new API functions or keywords: only two macros ( @gp for 2D plots, @gsp for 3D plots) and a basic knowledge of gnuplot are enough to generate most plots;
  • transparent interface between Julia and gnuplot to exploit all functionalities of the latter, both present and future ones;

This looks very nice! Any idea how one would use this for a DataFrame? E.g. how to replicate the “group” argument in Plots.jl ? Thanks!

Sorry - I think StatsPlots.jl adds the group argument .

Any ideas how well this works in Juno?

It would be easier to answer if you provide an example of the specific feature.

In general, Gnuplot.jl aims to be loosely coupled with other packages, but nothing prevents to add functionalities if their usefulness is widely recognized.

No, I never tried.
There currently is no integration with Juno, but the package should work just the same as with the REPL.

@gcalderone Just in case you want to implement this: the key to making plots appear in Juno’s plot panel is to output them with the correct MIME type. I chose to use SVG in Gaston, but PNG should work just as well. The relevant code in Gaston starts here and up to line 88.

3 Likes

Thank you very much! I’ll experiment a bit…
I’m definitely not an expert in Juno, but I believe it is not going to be the default output for Gnuplot.jl. As far as I can tell:

  • Juno support visualization of only one plot pane, while Gnuplot.jl support multiple windows;
  • A few native teminals (qt, wxt) support mouse integration and a few primitive annotations. This would be lost in Juno…;
  • Sending a plot to Juno involves writing a temporary file, which may not be an optimal solution;

Still, it may be useful to have a sendToJuno() function. Any PR on this topic would be welcome…

I’m with you 100% on this. However, I did want Gaston to support Jupyter. Once that was in place, adding Juno support was straightforward.

I for some reason can not give up ggplot. I don’t know if Plots.jl has all the capability yet and I have the GoG style stuck in my head. VegaLite is a nice alternative, but sometimes it takes me hours to do figure out how to do simple things. Maybe I’ll try gnuplot, since it’s a relatively old and established software.

Does anyone have an introduction to gnuplot blogpost or article they can share?

How about the gallery of demos: Demos for gnuplot version 5.4 ?

2 Likes

I’m not super familiar with ggplot because I deal with very basic data that is easy to visualize with gnuplot or other “traditional” plotting tools. From what I’ve seen, though, if you deal with datasets, categories, dataframes and that kind of statistical data, then ggplot is probably much better than gnuplot, in the sense that ggplot is optimized to generate the kind of plots you need.

I’m an astrophysicist mainly involved in data analysis, and I’ve never been in a situation where gnuplot can not provide a decent plot in a very short time.

A resources I highly recommend, beside the manual itself, is Gnuplot in action.

If you’re new to gnuplot I strongly suggest to identify your plot of intereset among the many resources online:

and then start from there.

2 Likes

Maybe if you share some of the examples or usual (simply plots) done with ggplot that you will like to see, I will be happy to add them to the gallery of examples with gnuplot.

2 Likes

Sorry - I’ll be more specific. Imagine you have a DataFrame of # of airplane flights by city and date. You want to plot the # of flights per day, but have a different line for each city appear on the plot. For StatPlots, you would do something like
@df flights plot(:Day, :NumFlights, group=:City)

Can gnuplots do this group option or does one need to split the dataframe and do it by hand? Thanks! – Adam