GNU Astronomy Utilities


Previous: , Up: Other useful software   [Contents][Index]


B.2 PGPLOT

PGPLOT is a package for making plots in C. It is not directly needed by Gnuastro, but can be used by WCSLIB, see WCSLIB. As explained in WCSLIB, you can install WCSLIB without it too. It is very old (the most recent version was released early 2001!), but remains one of the main packages for plotting directly in C. WCSLIB uses this package to make plots if you want it to make plots. If you are interested you can also use it for your own purposes.

If you want your plotting codes in between your C program, PGPLOT is currently one of your best options. The recommended alternative to this method is to get the raw data for the plots in text files and input them into any of the various more modern and capable plotting tools separately, for example the Matplotlib library in Python or PGFplots in LaTeX. This will also significantly help code readability. Let’s get back to PGPLOT for the sake of WCSLIB. Installing it is a little tricky (mainly because it is so old!).

You can download the most recent version from the FTP link in its webpage166. You can unpack it with the tar xf command. Let’s assume the directory you have unpacked it to is PGPLOT, most probably it is: /home/username/Downloads/pgplot/. open the drivers.list file:

$ gedit drivers.list

Remove the ! for the following lines and save the file in the end:

PSDRIV 1 /PS
PSDRIV 2 /VPS
PSDRIV 3 /CPS
PSDRIV 4 /VCPS
XWDRIV 1 /XWINDOW
XWDRIV 2 /XSERVE

Don’t choose GIF or VGIF, there is a problem in their codes.

Open the PGPLOT/sys_linux/g77_gcc.conf file:

$ gedit PGPLOT/sys_linux/g77_gcc.conf

change the line saying: FCOMPL="g77" to FCOMPL="gfortran", and save it. This is a very important step during the compilation of the code if you are in GNU/Linux. You now have to create a folder in /usr/local, don’t forget to replace PGPLOT with your unpacked address:

$ su
# mkdir /usr/local/pgplot
# cd /usr/local/pgplot
# cp PGPLOT/drivers.list ./

To make the Makefile, type the following command:

# PGPLOT/makemake PGPLOT linux g77_gcc

It should finish by saying: Determining object file dependencies. You have done the hard part! The rest is easy: run these three commands in order:

# make
# make clean
# make cpg

Finally you have to place the position of this directory you just made into the LD_LIBRARY_PATH environment variable and define the environment variable PGPLOT_DIR. To do that, you have to edit your .bashrc file:

$ cd ~
$ gedit .bashrc

Copy these lines into the text editor and save it:

PGPLOT_DIR="/usr/local/pgplot/"; export PGPLOT_DIR
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgplot/
export LD_LIBRARY_PATH

You need to log out and log back in again so these definitions take effect. After you logged back in, you want to see the result of all this labor, right? Tim Pearson has done that for you, create a temporary folder in your home directory and copy all the demonstration files in it:

$ cd ~
$ mkdir temp
$ cd temp
$ cp /usr/local/pgplot/pgdemo* ./
$ ls

You will see a lot of pgdemoXX files, where XX is a number. In order to execute them type the following command and drink your coffee while looking at all the beautiful plots! You are now ready to create your own.

$ ./pgdemoXX

Footnotes

(166)

http://www.astro.caltech.edu/~tjp/pgplot/


Previous: , Up: Other useful software   [Contents][Index]