
			GNUPLOT for XSPECT
MJF-1/16/96
    3/02/03
    1/08/04
    1/10/05
    1/12/13

Gnuplot:

	Gnuplot is a command line plotting program for the generation
	of two and three dimensional plots that runs on all major
	operating systems (Unix/Linux, Windows, Mac OS, ..).
	It is well suited for script driven graphics.

Installation:

	The official website for gnuplot is;

		http://www.gnuplot.info/

	The link at the lower left for 'version 4.6 demo gallery'
	goes to a page with numberous command scripts that
	illustrate the diverse capability of the software.
	Use the 'Download from SourceForge' link to obtain the software.

	For Windows, use the link for the latest version
	('Download gp460-win32-setup.exe(9.9 MB) as of 12-Jan-2013'.
	Do not use the green 'Download' button at the right (12-Jan-2013),
	it is associated with an advertisement and will install JunkAPPS
	along with gnuplot.

	The installer, gp460-win32-setup.exe, will install the application
	in Program Files and will associate certain extensions.
	You will be asked to select certain installations options,
		- Select the Windows terminal.
		    This will create an environmental variable
		    that can be changed later.
		- Select the path addition.
		    This will add the path to the gnuplot bin directory
		    to the system path variable.
	Otherwise leave the default selections for the file extensions.
	
	After installation, look in the gnuplot folder in the start menu
	programs menu. 'gnuplot documention' is a pdf book for gnuplot
	that documents the behaviour of all commands. Similar information
	in in the 'gnuplot Help' application in windows help format.

	To verify the installation, execute 'gnuplot 4.6' from the start menu.
	A command window should open. In response to the gnuplog> prompt,
	enter the simple command: plot sin(x)
	A second window should open with the sin function plotted.

	Many Unix/Linux and Mac OS systems will have gnuplot already installed.
	In not, it is typically downloaded as source code from the above
	site and made on the users system. 'gnuplot documention' is a pdf book
	for gnuplot documenting the behaviour of all commands. Similar informatiton

Plotting datafiles:

	format of data:

		Data files should be in columns with space delineation.
		Comment lines can be included by using the # character at
		the beginning of the line.

	plot command:

		Use the plot command to plot the data , 
		
			plot "datafile" using 1:3
		
		where 1:3 refers to columns 1 and 3. Many other useful options
		can be added to the plot command lines. For example,
		
			plot "datafile" using 1:3 w l

		plots the data with lines.

	Styling the plot:

		A variety of commands are available to put labels
		on the axis, titles on the graph, or legends on the
		curves.  For example,

			set xlabel "millimeter"

		See the help files for the available options under set.
		A problem often encountered is putting labels on the
		legend for the plot. This is done with the plot
		command as:

			plot "datafile" using 1:3  title "mydata"

	Adding another curve:

		After the initial plot use,

			replot "datafile" using 1:2

		to add another curve to the same graph.

	Changing plot ranges:

		To change the range of values on the axis,

			set xrange [10:80]
			set yrange [0:200]

		then use the replot command with no arguments to
		refresh the screen.

Saving plots:

	The 4.6 version of the windows terminal provides for saving
	a plot as an extended metafile, *.EMF.
	Start gnuplot 4.6 and change the working directory to that
	where there is a datafile such as that from "TCL for XSPECT".
	For example:
	
		cd 'C:\XIRL\_Rad-Img\_xspect3.5\_Examples'

	Then plot the data using a command such as

		plot "TEMP_lab01.txt" w l title "lab01"

	Note the use of the quotes that gnuplot requires

	Then, using the toolbar at the top, save the file as an EMF file.
	The plot window size and aspect can be changed and will be
	saved as seen in the EMF file. These EMF files can be easily
	imported to microsoft ofice documents.

Command files:

	For the ActiveState gnuplot installation, text files with
	an 'gpl' extension, *.gpl, with be executed with the
	wgnuplot.exe file in the gnuplot installation bin directory.

	In the directory where the above 'datafile' is located,
	create a new text document and open it with notepad.
	Write the following,

		plot "TEMP_lab01.txt" w l title "lab01"
		pause -1 "Lab 01 Example"

	Comments can be added to these files by placing
	# at the beginning of the comment line.

	Save the file with a .gpl extension: Ex01_Intro_A.gpl
	Executing this file should open a window with the plot.
	Later, we will create plot commands
	and execute them directly using tcl commands.

Graphic files:

	gnuplot support a large number of output formats that can
	generate image files with graphic content.
	For the .gpl file created above, add the following content,

		set terminal png size 500,500 font "Times New Roman, 14"
		set output "temp-gpl.png"
		plot "TEMP_lab01.txt" w l title "lab01" smooth csplines
		pause -1 "Lab 01 Example"
		exit

	When execute, the added commands will generate the png file
	and gnuplot will exit after the second command.
	In this example, several plot properties have been adjusted,
		- The plot size is set to 500 x 500 pixels
		- The font is set to Times New Roman
		- The curve has been smoothed with a cubic spline operation.
	To access the full font set, the following environmental variable
	should be set in the windows OS,
		GDFONTPATH C:\WINDOWS\FONTS


Further information:

	The gnuplot documention provided as a pdf file provides the most complete
	information on available commands along with the windows help applications.

	The gnuplot homepage has a page with links to tutorials and learning material
		http://www.gnuplot.info/

	An interesting blog from a physicist can be read at
		http://www.gnuplotting.org/
	

