Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
GnuPlot Tutorial<br />
1. Type <strong>gnuplot</strong> at the unix terminal, it will open an interactive session.<br />
2. We will start by making some simple plots at the command line<br />
1. Type plot 4 and hit enter. View the resulting graph.<br />
2. Type plot x and hit enter.<br />
3. Type plot 4,x and hit enter. You should see both of these lines in the same figure now.<br />
3. Now we will change up the axis labels<br />
1. With your previous figure still open, go back to the <strong>gnuplot</strong> command line.<br />
2. Type set xlabel 'X-axis' and hit return. You should see that nothing comes up yet on the<br />
graph. Now type replot and hit enter. Now change the y axis label by typing set ylabel 'Yaxis'.<br />
Of course, you can make these labels whatever you want.<br />
4. We will label plots now.<br />
1. Type plot sin(x) title 'Sine Function' and hit enter.<br />
(1) You should see 'Sine Function' appear somewhere on the graph of the sine function. You<br />
probably also see 'Y-axis' and 'X-axis' on the figure. Let's remove those by typing set<br />
xlabel ''; set ylabel ''; replot and hitting enter.<br />
5. Other formatting options<br />
1. Let's start with a new graph. Type plot x**3 – 3*x**2 + 4*x – 2 title 'My Graph', x**3 +<br />
3*x**2 – 4*x + 2 title 'My Other Graph'<br />
2. Type set xrange [-20:20]; set yrange [-10000:10000]; replot<br />
3. Type set key -5,8000; replot<br />
4. Type set xlabel 'X-axis'; set ylabel 'Y-axis'; set title 'My Graph'; replot<br />
6. Now we will see how to load data from a data file into <strong>gnuplot</strong>, and to load the commands we<br />
want to use for plotting from a script instead of from the interactive command line.<br />
1. Start a new <strong>gnuplot</strong> session. Type exit and hit enter. Then type <strong>gnuplot</strong> to start <strong>gnuplot</strong> up<br />
again.<br />
2. Make sure that <strong>gnuplot</strong>_data.dat and <strong>gnuplot</strong>_plot_script.p are in the same directory. Type<br />
load '<strong>gnuplot</strong>_plot_script.p' at the prompt and hit enter.<br />
3. You should see a figure with three curves come up. The commands in the<br />
<strong>gnuplot</strong>_plot_script.p file issued the commands necessary to make this figure, using data in<br />
the <strong>gnuplot</strong>_data.dat file. Take a look at these files in another terminal window using nedit<br />
or vi.<br />
7. We will finish by saving figures.<br />
1. Type set terminal postscript and hit enter<br />
2. Type set output 'graph.ps' and hit enter<br />
3. Type replot and hit enter<br />
4. Type set terminal png and hit enter<br />
5. Type set output 'graph.png' and hit enter<br />
6. Type replot and hit enter<br />
7. Now type exit and hit enter to exit <strong>gnuplot</strong>.<br />
8. Type ls at the unix prompt and you should see the files graph.ps and graph.png<br />
9. Type gimp & and open the figures to look at them.
XMGrace Tutorial<br />
1. Type <strong>xmgrace</strong> & at the unix prompt.<br />
1. You should see a screen pop up with lots of menus and an empty graph.<br />
2. Go to Data, Import, Ascii<br />
3. Under Load as, choose Block Data<br />
1. If you had a data set with only two columns, this step would not be necessary. But our data<br />
has multiple columns in it, so we need to load as 'Block Data' so that we can tell XMGrace<br />
which columns we want it to plot.<br />
4. Double click on the data file in the window, and then another window will open asking you to<br />
Edit block data. For X from column choose 1, and for Y from column choose 3, then click<br />
Apply. Now change Y from column to 4 and click Apply, and finally change Y from column<br />
to 5 and click Apply. Then close the Edit block data window, and the Data Import windows.<br />
5. You should have three lines, a black, red and green line. Xmgrace will cycle through colors in a<br />
specific order as you add lines.<br />
6. Double click on the x-axis and an axis editing window should come up. It should be fairly selfexplanatory,<br />
so play with the various options in here and try changing x-limits and axis labels,<br />
or tick spacings. You'll have to hit Apply to see the changes type effect. You can also edit the<br />
y-axis from this menu by changing from x to y at the top. Go through the various tabs and see<br />
what options you have as well.<br />
7. Go to Plot menu and then Graph Appearance. You can add a graph Title and Subtitle here,<br />
and with the other tabs do things like change where the Legend box will be for the various<br />
curves.<br />
8. Go to Plot menu and then Set Appearance to change things about the data sets. You can<br />
change line styles, line colors, etc using these menus. So play with these and see what you can<br />
do with your figure.<br />
9. Finally we'll save our session and print a figure. '<br />
1. Go to File menu and then Save as<br />
2. At the bottom in the Selection box go to the end of the line and type grace_figure.agr and<br />
then click OK to save.<br />
1. This is a grace file, and if you open it later in another session of <strong>xmgrace</strong> it will load<br />
back in all the stuff you have done so you can continue working on your graph.<br />
2. Now go to File and Print setup. For Device leave it as Postscript. In the File name<br />
box it should be the name of the <strong>xmgrace</strong> file then .ps, you can change it to whatever<br />
you want though. Click Apply.<br />
3. Go to the File menu and then to Print<br />
4. Now go to your unix terminal and type ls, and you should see your file printed to a ps<br />
file. Type gimp & and then open the file to look at it.<br />
10. You can do lots of stuff with XMGrace, this is the plotting software I prefer, so it is worth your<br />
time to get to know the ins and outs of this software.