• Active Topics 

Install and Test Gnuplot Version 5.0 from the Source on Unix

Post Reply
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5219
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#1

We are going to show you how to install Gnuplot on Ubuntu Linux. Gnuplot is simple to install and use on Ubuntu systems since it is already included in the Ubuntu repositories. However, it is always a good practice to install the latest stable version from the source https://sourceforge.net/projects/gnuplot/files/gnuplot/. To install Gnuplot 5.0.3 on Ubuntu Linux version 12.04 and above, follow instructions below.

# Download source code

Code: Select all

wget http://sourceforge.net/projects/gnuplot/files/gnuplot/5.0.3/gnuplot-5.0.3.tar.gz
# Open the terminal and extract archive

Code: Select all

tar -xvzf gnuplot-5.0.3.tar.gz
#`cd' (move) to the directory containing the package's source code:

Code: Select all

cd gnuplot-5.0.3
# Type configure gnuplot for compilation

Code: Select all

./configure
# Compile the package by typing (Optionally, type `make check' to run any self-tests that come with the package)

Code: Select all

make
# Type `make install' to install the Gnuplot in default location plus any data files and documentation

Code: Select all

sudo make install
#You can remove the program binaries and object files from the source code directory by typing

Code: Select all

make clean
# To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type

Code: Select all

make distclean
Or you clean up installed files including the gnuplot-5.0.3 folder if you do not need it (do the same for gnuplot-5.0.3.tar.gz) :

Code: Select all

cd .. 
rm -r gnuplot-5.0.3
(recursively remove files and gnuplot-5.0.3 folder)

# Return to the parent/Home directory

Code: Select all

cd ../../
# Tell user that Gnuplot was successfully installed

Code: Select all

echo "Gnuplot was successfully installed and works like a charm!"
We have now successfully installed gnuplot, type 'gnuplot' on the terminal to test it. In order to enable auto completion, type the following command in Terminal

Code: Select all

gedit ~/.bashrc &
Add the following lines to the file, somewhere, preferably near the bottom (Don't forget that lines starting with # are comments which remind you what the line next to them is all about)

Code: Select all

# enable autocompletion in gnuplot
alias gnuplot="rlwrap -a -c -b\"\\\"\\\"\\\'\\\'\" gnuplot" 
Finally, save the file and exit.

These instructions can easily be adapted for higher versions of Gnuplot on Unix machines.

Let's now test the Gnuplot by pltotting some data. Create a folder named "Gnuplot" on the Desktop, download some data file from here, and save it in the directory Gnuplot. The name of the file is 'testResults.dat'.

Open the Terminal and move to the directory by typing

Code: Select all

cd Desktop/Gnuplot/
Type gnuplot in the command line, you should see the window below (You may however need to install rlwrap by following instructions here, but remember to replace vivid by the appropriate Ubuntu version name).
gnuplot_window.png
Then type in the command prompt

Code: Select all

p 'te 
and press the tab key. The filename should auto complete to 'testResults.dat'. Press Enter. If it works you should see the following window:
gnuplot_window2.png
Try to plot with lines, by typing in the command line prompt

Code: Select all

p 'testResults.dat' w l
The resulting graph should look like this
gnuplot_wl.png
Finally, plotting using the command

Code: Select all

p 'testResults.dat' using 1:2 with boxes
yields
gnuplot_w1_2.png
See also http://www.gnuplotting.org/output-terminals/, set terminal to x11

Note: After installing and instantiating Gnuplot, you may encounter the problem 'Terminal type set to unknown', this is usually caused by some missing dependencies mentioned at the end of the script generated after issuing ./configure command. You may see something like this:

Code: Select all

wxt terminal: no (requires C++, wxWidgets>2.6, cairo>0.9, pango>1.10)
  Qt terminal: no (use --with-qt or --with-qt=qt4 to enable
Check the discussion at ubuntuforums and C++, g++, wxWidgets.

At this stage you may need to uninstall (and re-install again, later, after installing all the required dependencies) gnuplot, depending on the version you have installed, by typing

Code: Select all

sudo apt-get remove gnuplot5
to remove Gnuplot version 5 package only.

Or

Code: Select all

sudo apt-get remove --auto-remove gnuplot5
to uninstall Gnuplot version 5 package and it's dependencies.

See more uninstall alternatives.

To install Cairo package go to http://www.linuxfromscratch.org/blfs/vi ... cairo.html or https://launchpad.net/ubuntu/+source/ca ... .6-1build1 and http://askubuntu.com/questions/108662/h ... iro-1-8-10

For Pango install, check http://www.linuxfromscratch.org/blfs/vi ... pango.html
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Post Reply

Return to “Gnuplot, Maxima/XMaxima”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest