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

Heh, I just noticed that Gaston ignores ms, it’s a bug: https://github.com/mbaz/Gaston.jl/issues/143

In the mean time, you can use pointsize, ps or markersize to specify the marker size. I’ll fix this in the next release.

2 Likes

I could not find a .gnuplot.ini file in Windows. I assume I just have to create it. The gnuplot startup instructions are not very specific, but it says to place the .gnuplot.ini file under the AppData folder in windows. I created a folder and placed it here:

C:\Users\myusername\AppData\Roaming\gnuplot\.gnuplot.ini

It’s not being picked up. Do you have better direction?

gnuplot\.gnuplot.ini

The filename needs to be (I think) GNUPLOT.INI.

Edit: you seem to have a dot at the start of the filename.

In my windows machine I have this file: C:\Users\<ME>\AppData\Roaming\GNUPLOT.INI

1 Like

Excellent, that worked. I did have to remove the first line of the .INI file ($ cat .gnuplot) or I get the error below. I assume that line is not critical.

┌ Warning: Gnuplot returned an error message:
│   
│ gnuplot> $ cat .gnuplot
│                ^
│          "C:\Users\myusername\AppData\Roaming\gnuplot.ini" line 1: data block name must be followed by << EODmarker
│ 
└ @ Gaston C:\Users\myusername\.julia\packages\Gaston\FSgDg\src\gaston_llplot.jl:182

Great package by the way. I think it is a very good option for plotting in Julia.

2 Likes

Yeah, the $ cat gnuplot was the Linux command I used to print the file to the screen. Sorry for the confusion.

Thank you for the feedback!

2 Likes

I am currently using IJulia/Jupyter. I see I can change on-screen plots size with:

set(termopts="size 500,400")

Is there a way to change plot size from within the plot() function?

No – in gnuplot, the only place where the plot size can be specified is in the set terminal line, In Gaston, setting the terminal is seen as a long-term configuration, so it is not exposed by plot.

I guess that could be changed, but will require a bit of work. Please file an issue so I don’t forget.

2 Likes

Done

1 Like

Is there a way to keep the on-screen formatting in an svg output of a plot? I am using Jupyter Notebook. Below is an example plot I am trying to export:

using Gaston; set(termopts="size 600,400")
using SpecialFunctions

f(γ) = exp(-1im*γ*zs)*(besselk(0,abs(γ)*rqc) - besselk(0,abs(γ)*rqic))/(besselk(0,abs(γ)*raρ) - besselk(0,abs(γ)*raiρ))

γ = range(-10,10,length=2^10)
h = 10.0
raρ = 0.02
raiρ = 2*h
rqc = 1
rqic = sqrt(rqc^2 + (2*h)^2)
ri = sqrt(5^2+20^2)
zs = 10

plot(γ,real.(f.(γ)),
    curveconf = "w l lw 1.5 t 'Real'",
    Axes(xrange=(-5,5),yrange=(-0.5,0.6),xtics=(-5:1:5),
        title = "'Example ~G{1.0\\~} _{ρq} Frequency Response (includes images)'",
        xlabel="'Frequency (1/meters)'",
        ylabel = "'Magnitude'",
        axesconf="""
        set label 1 at -5, -0.3
        set label 1 'γ range = ±5 [1/m]'
        set label 2 at -5, -0.4
        set label 2 'Samples = 256'
        """))
plot!(γ,imag.(f.(γ)),curveconf = "w l lw 1.5 dt (10,5) t 'Imag'")

On screen result (obtained by screenshot)

image

When I then execute this code:

save(term = "svg", output = "outExample.svg")

I get the following (again screenshot since Discourse does not support svg files):

The png terminal retains the formatting, but I would prefer to use svg in certain circumstances.

2 Likes

One thing to keep in mind is that each gnuplot terminal has its own defaults. In addition, Gaston distinguishes between options used when plotting and options used when saving, since in many cases these will be different.

In your example I see two problems; let me know if I’m missing something. One is the title, and the other is the font size.

Regarding the title, it seems like the svg terminal is not interpreting the title string the way the png terminal does. This title seems to work:

title = "'Example G̃_{ρq} Frequency Response (includes images)'"

The font can be selected from the save command:

save(term = "svg", font = "Arial, 16", output = "outExample.svg")

With these two changes I got this SVG image, as rendered by Firefox:

image

4 Likes

Thanks for the great package – always nice to have more plotting option!

I was wondering whether you’ve considered extending the docs regarding outputting latex-compatible graphs? The docs allude to it being possible, but don’t elaborate on how to achieve it.

2 Likes

Gnuplot in Action book describes LaTeX-Gnuplot interaction in Section 10.4.

4 Likes

You’re very welcome, and thanks for the kind words. I’ll make sure to add something next time I update the docs (https://github.com/mbaz/Gaston.jl/issues/152). Of course, pull requests are always welcome :slight_smile:

1 Like

I had heard about this book, but I hadn’t realised it can be read online for free. Thanks for the pointer!

Thank you for your work. I’m not fan of GNUPlot but many people around me are, so this is very handy package for me, to avoid using GNUPlot directly.

Do you write down somewhere reflections on working on this package? Since it taken eight years (since Julia has official premiere in 2012 I wonder if seven years is more accurate?) to arrive at version 1.0, this can be very interesing reading.

I did a gallery with a few examples on how to use Gnuplot.jl [similar to Gaston], so that people can find easily [copy and paste] examples and start working. Take a look.

3 Likes

@KZiemian Interesting suggestion! I’ve wanted to start a blog for a long time, but haven’t found the time. If I do, I’ll write a post on this subject.

BTW, I started Gaston back in April or May of 2012. I used bitbucket at the time, and they seem to have deleted my repositories, so that early history may be lost, unless I have a backup somewhere.

1 Like

@lazarusA Many of the examples in my own examples (2-D, 3-D) are inspired by, or just taken from, your amazing Gnuplot.jl gallery.

is there a way to see what terminal types are available? I install gnuplot on a Mac but Gaston gives the following error when I run through Atom

┌ Warning: Gnuplot returned an error message:
│   
│ gnuplot> set term qt 1 size 30,10 ansirgb
│                   ^
│          line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list
│ 
│ WARNING: Plotting with an 'unknown' terminal.

I also get a similar error with sixelgd.

The easiest way is to open gnuplot in a terminal and run set term. On Mac, the aqua terminal is recommend (but I haven’t tested it myself, since I don’t have access to one).

2 Likes