r1 - 20 Oct 2009 - 14:27:47 - SusieBurdettYou are here: Astrophysics Wiki >  WelcomeToExeter Web  >  TeamInfo > HowTo > PlottingHowto
When you first arrive you may know little about the different plotting tools available. This is something which you will no doubt find yourself doing a lot so a little effort to learn one or two methods will save you a lot of time. Do not think that Excel serves all your plotting needs. It does not.


For quick plotting Gnuplot can be very handy. It will probably already be installed on your machine, so to begin type "gnuplot".

* example_plot.tar.gz: Files to create an example plot in gnuplot

Below is a simple example.

% gnuplot

% plot [0:1] [50:-5] "data_line.txt" w l, "data_points.txt" u ($1):($3*10) w p

This first line starts the gunplot environment in a terminal. The second line plots the data in data_line.txt as a line, the data of data_points.txt as points (column one on the x-axis and column three times 10 on the y-axis). This will all be plotted over an x-range of 0 to 1, and a y-range of 50 to -5.

Gnupot will give each line or point a different colour (up to 8?) unless you specify a line type (lt 1 w l instead of just w l). You can also put this into a file (say plot.plt) and run from the command line with either

% gnuplot "plot.plt"

or start the gnuplot environment first (% gnuplot) and then

% load "plot.plt"

This can be useful if you are creating a complicated plot which you would like to produce again quickly.

Another gnuplot example

set term postscript enhanced eps color solid

set output "plot.eps"

set encoding iso

set label "0.070" at 1.840,13.44

set label "0.072" at 1.640,12.80

set label "0.075" at 1.240,11.78

set label "0.080" at 0.850,10.82

set label "0.090" at 0.750,10.04

set label "0.100" at 0.550,9.62

set xlabel "(K-L)"

set ylabel "M_{K}"

plot [0:5] [20.5:8.5] "data.txt" u ($11-$12):($11) w l

set output

set term pop

The first line sets the terminal type to postscript. This is instead of the default which may be aqua (or some other graphics window). Here we set it to be a color postscript, otherwise the coloured lines will be converted to full, dotted, dashed lines etc. which may be better for black and white printing. set output "" names the postscript file to which you are writing. Another set output at the end closes the file. the final line sets the terminal type back to the default.

See http://t16web.lanl.gov/Kawano/gnuplot/index-e.html for a guide on how to do just about anything with gnuplot.

See also the IBM page which gives a short useful introductory tutorial.


PGPLOT is a library of subroutines which can be called from FORTRAN, C, Perl, and other languages. One can construct rather more complicated plots with PGPLOT than with gnuplot, though the production of these is may be similarly complicated.

PGPLOT is available as a module for Perl and PDL (Perl Data Language) at CPAN.

Ark Graph

The graph program in Tim Naylor's ark software suite can be very useful, especially if you are dealing with ark format catalogue files. This requires an ark installation. If you have this, source the ark and then type graph to begin. There are several defined macros which can produce common plots.

One bizarre feature of graph is that it ignores the first 3 lines of your file! This is to allow you to put a human-meaningful header at the top of the file. So if you are reading data, make sure your file has three empty lines at the top, or your graph will be truncated.


Proprietary and not always available.

SM (SuperMongo)

Proprietary and not always available.


Splot is a package in IRAF which can be to plot most things within the CL environment. It is most useful to plot spectra when using IRAF for the extraction or for plotting fits during data reduction.


SPLASH is Daniel Price's visualisation tool for output from (astrophysical) simulations using the Smoothed Particle Hydrodynamics (SPH). It uses PGPLOT in FORTRAN90.


Plot is a pretty grapher for Mac OSX. It produces nice output and can output to PDF etc. Does loads of clever things and interface is reasonably intuitive.

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions

key Log In or Register

Main Web Users Groups Index Search Changes Notifications Statistics Preferences

Webs Main Sandbox TWiki Zen Information

Main Web Users Groups Index Search Changes Notifications Statistics Preferences

Webs Main Sandbox TWiki Zen

Astrophysics Wiki

Edit Wysiwyg Attach Printable
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Astrophysics Wiki? Send feedback