LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Making a simple graph with Gnuplot 4.6? (https://www.linuxquestions.org/questions/linux-software-2/making-a-simple-graph-with-gnuplot-4-6-a-4175602142/)

Xeratul 03-19-2017 03:52 PM

Making a simple graph with Gnuplot 4.6?
 
Hello,

I am trying to use gnuplot but nothing works:
Code:

dpkg -l | grep gnuplot
ii  gnuplot                            4.6.6-2                              all          Command-line driven interactive plotting program
ii  gnuplot-data                        4.6.6-2                              all          Command-line driven interactive plotting program. Data-files
ii  gnuplot-qt                          4.6.6-2                              i386        Command-line driven interactive plotting program. QT-package
ii  gnuplot-tex                        4.6.6-2                              all          Command-line driven interactive plotting program. Tex-files

with any files, it results in error.


src: http://gnuplot.sourceforge.net/demo_4.0/steps.1.gnu


Code:

gnuplot steps.1.gnu

set title "Compare steps, fsteps and histeps" 0.000000,0.000000  font ""
                                              ^
"steps.1.gnu", line 3: ';' expected


with gnuplot 5 same story:
Quote:

gnuplot5 simple.5.gnu

set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front noinvert bdefault
^
"simple.5.gnu", line 26: invalid colorbox option
http://gnuplot.sourceforge.net/demo_5.0/simple.html

Gnuplot looks a bit buggy and non reliable,...

rtmistler 03-21-2017 12:55 PM

I think there are legitimate syntax errors in your terms, which is what gnuplot is telling you.

You can't put x,y in the title, instead I think you need to set key to locate it other than the default. If I remove the x,y from that, mine works.

You are not supposed to have the term screen following origin or size in the colorbox set, the zero before front is also incorrect, as is the noinvert. If I remove the two "screen" terms, the 0 before front, and the "noinvert" it also works correctly.

At least according to the 4.6 documentation: http://www.gnuplot.info/docs_4.6/gnuplot.pdf

astrogeek 03-21-2017 01:23 PM

The linked file does contain errors, probably due to naive copy/paste from some earlier example that nobody tested.

Go back one page to the page which links that file and copy/paste the gnuplot code shown there...

Code:

set title "Compare steps, fsteps and histeps"
plot [0:12][0:13] "steps.dat" notitle with points,  \
 "steps.dat" title 'steps' with steps, \
 'steps.dat' title 'fsteps' with fsteps, \
 'steps.dat' title 'histeps' with histeps

...paste that into the file steps.1.gnu (in the same directory with the steps.dat file), then...

Code:

gnuplot -p ./steps.1.gnu
...it works.

It would probably be a good learning exercise for you to compare the two and find the errors.

Gnuplot is not buggy, well, no more so than any other piece of software. But the syntax can be very rich, and prone to operator error - but well worth learning!

I would suggest setting up a directory where you systematically explore each major syntax feature in your own examples and keep notes! I have such a workspace which I have maintained over the years, with accumulated notes and examples which allow me to work out new plots easily when required.

Update - I looked at a few more examples from the links in your original post and found there are indeed others with errors, others without errors.

The problem appears to be that the linked code has been autogenerated from an earlier HTML version of the website, or other source, without anyone actually checking them. From the top of the V5 examples page...

Code:

autogenerated by webify.pl...
In the initial examples I checked, the code shown in page with the plots is correct, and the linked code has errors. But I also found counter examples where the linked code was correct and in-page code was incomplete.

You may want to consider notifying the project website maintainers as well.


All times are GMT -5. The time now is 04:13 AM.