[ANN] Gaston v1.0.0 -- Plotting using gnuplot

I’m happy to announce version 1.0.0 of Gaston, a julia front-end for gnuplot. More than eight years in the making, for the first time I’m happy enough with Gaston’s API and robustness to make the jump to version 1.0.

The documentation can be found here.

Gaston has similar capabilities to Gnuplot.jl, but a different approach – Gnuplot.jl allows one to basically “write gnuplot” in Julia using macros, whereas Gaston has a more traditional interface, based on plot-like functions.

In addition, Gaston is very fast. On my i5 IceLake laptop, I can load the package, plot and save to pdf in less than six seconds; subsequent plots are obviously much faster:

julia> @time begin using Gaston; plot(1:1000); save(term="pdf",output="test.pdf"); end
  5.660489 seconds (20.42 M allocations: 1.035 GiB, 6.08% gc time)

Commens, issues and pull requests are welcome!

37 Likes

Looks lovely.

2 questions with your permission:

  1. When displaying images, is there a way to set the view to 1:1 mode? Namely each pixel in the data is 1 pixel on screen? How will it handle HiDi cases?
  2. Is there a potential / way for interactivity with the data? Simple interactivity as Panning, Zooming and Data Tips (Namely seeing the value itself). Or is it a limitation by GnuPlot?

Thank You.

2 Likes

Thanks!

I don’t think gnuplot has a 1:1 zoom mode. One way to achieve something similar would be to plot using the “points” style (that is, plot only the markers), and select as marker a “dot”, which is a single pixel:

x = y = -15:0.4:15
f1 = (x,y) -> @. sin(sqrt(x*x+y*y))/sqrt(x*x+y*y)
surf(x, y, f1, w = :p, marker = "dot", Axes(hidden3d = :on))

pixels
Here, every dot on the plot is one data point. If the pixels are too small to see, you can use “full circle” markers and set the size appropriately.

Yes, this is supported by Gnuplot. When plotting to the screen using a terminal such as qt, you can zoom and pan using the mouse. In 3-D mode, you can also rotate and scale the surface.

EDIT: forgot to add: when plotting to a browser, some mouse interactivity is provided by the “svg” terminal with the “mouse” option.

These are features I don’t use much myself; if you try them out, please file an issue if you find any problems.

1 Like

I meant 1:1 mode in the context of displaying image (imagec()). Any notes in that context?

Does the qt mode allow exploring the data using data tips?
Something like that:

image

The image pixels plotstyle should do what you want, I think.

The qt terminal does allow setting data tips. Use the mouse middle button:

image

1 Like

Thinking more about this, I think the way to do it is to set the plot size equal to your data size:

i = 255*rand(Int, 256, 256);
set(termopts = "size 256,256")
imagesc(i, Axes(tics = :off, colorbox = :off))

image

1 Like

Is there a way to align them to data plotted or they are free in coordinate system?
What will be their value in case of scaled image?

It seems they can be placed arbitrarily, at least in the qt terminal. And, it seems that they work the same way when plotting an image, since images also have x and y ranges.

Does Gaston accpet date or time as x-axis?

Short answer: yes, it does, to the extent that Gnuplot does (see page 49 in the manual).

Here’s a simple example:

using Dates
values = [0.2, 0.3, 0.5, 0.38, 0.18];
dates = [DateTime(2013,6,1,0,0),
         DateTime(2013,6,10,9,30),
         DateTime(2013,6,18,13,05),
         DateTime(2013,7,4,20,35),
         DateTime(2013,7,13,17,18)];
plot(Dates.format.(dates, "dd/mm/yy HHMM"), values, u = "1:2",
       Axes(xdata = "time",
            timefmt = "'%d/%m/%y %H%M'",
            style = "data fsteps"))

image

1 Like

My question was about the value of the element the Data Tip is aligned to.
Namely, on 1D Plot it will show the x value and the value of the function (Usually y).
On image I expect it to shoe the pixel coordinate and the value. If the image is scaled, the scaled value.

Very nice package !! Can a Gnuplot JLL be made? To avoid installing gnuplot on the system

5 Likes

Thank you!

There’s an issue open regarding a Gnuplot artifact: https://github.com/mbaz/Gaston.jl/issues/135

I haven’t figured out the artifacts system yet, but pull requests are very welcome. Otherwise, I’ll give it a shot sometime in the next few weeks.

3 Likes

From my experiments, I don’t see Gnuplot doing what you want; it just annotates the point where you click, regardless of the plotted data.

I think that gnuplot’s labeling mechanism can be leveraged to do what you want (see page 140 in the manual). However, interaction wouldn’t be with the mouse, but by giving commands from Julia. This might be a good addition to Gaston, if we can come up with a workable interface.

2 Likes

I’m new to Gnuplot and Gaston so apologies if this is a simple question, but I am not finding a clear way to remove some default markers that show up in plots. Is there some location where default plot style settings are located? For example, below I have no marker set, but plus signs show up.

Also is there a way to change the default color palette and line width?

Finally, how do you turn off a feature that shows up automatically, like the legend? If I leave off the legend in the code below, the plot shows up with the file path and data regarding plot points.

x = 0:0.1:15
y = sin.(x)

begin
plot(x,y,w=:lp,lw=2,lc=:blue,legend = :A_sine_wave,
    Axes(xrange=(0,15),yrange=(-1.5,1.5),xtics=0:1:15,ytics=-1.5:1.5))

save(term="svg",output = "c:/00_Temp/test.svg")
end

test

Gaston has no defaults on its own – any option that is not explicitly set by the user, will be left unspecified, so gnuplot will use its defaults.

Gnuplot’s defaults are less than optimal, though, so it is recommended to use a configuration file. This is described in the documentation, here. In this file, you can set the defaults you mention (legend, line width, line color) and many more.

This is my own gnuplot configuration:

$ cat .gnuplot
# set encoding
set encoding utf8

# define linetypes
set linetype 1 lw 1.3 lc rgb '#373CFF' pt 3  # blue
set linetype 2 lw 1.3 lc rgb '#8b1a0e' pt 4  # red
set linetype 3 lw 1.3 lc rgb '#5e9c36' pt 6  # green
set linetype 4 lw 1.3 lc rgb "black" pt 12
set linetype 5 lw 1.3 lc rgb "turquoise" pt 5
set linetype cycle 5

# plot data with style "lines"
set style data lines

# don't show the key by default
set key noautotitle

# don't mess with the ranges
set auto fix

# breathing room around the curves
set offsets graph .05, graph .05, graph .05, graph .05
4 Likes

Thanks. I also just noticed that when I try to change the marker, for example to “ecircle”, the letter e shows up as the marker. Would this also be corrected by the configuration file you posted?

Since gnpulot can use any single character as marker, I’d guess you’re inadvertently (somehow) passing an e instead. Are you sure you’re enclosing "ecircle" in double quotes?

t = -5:0.05:5;
plot(t, sin, w = :lp, marker = "ecircle", ps = 2, pn = 5)

image

1 Like

I need to get my glasses on. I had “circle” not “ecircle” and they were c’s not e’s. However, once I corrected that I noticed that changing the value of ms does not change the size of the markers. Any ideas there?

Ok, I see you just changed from ms to ps, which does work for me.