gnuplot / intro / plotexp (E)
Introduction to gnuplot — Experimental DatPreparation of Data File Here we describe how to plot experimental data in a data file. # Data No. 1 2.1500E-02 1.3060E+00 5.3098E-02 2.3900E-02 1.2220E+00 4.7043E-02 2.6800E-02 1.3430E+00 4.9854E-02 2.9700E-02 1.2580E+00 4.5860E-02 3.2500E-02 1.2430E+00 4.4506E-02 .... 9.4500E-01 1.2290E+00 3.7317E-02 1.0350E+00 1.2630E+00 4.1449E-02 1.1330E+00 1.2670E+00 4.2289E-02 # Data No. 2 2.4000E-02 1.2970E+00 3.1387E-02 4.0000E-02 1.3060E+00 2.8993E-02 6.0000E-02 1.2960E+00 2.8382E-02 8.0000E-02 1.3300E+00 2.8728E-02 .... 7.0000E+00 1.2210E+00 2.5031E-02 7.2000E+00 1.1990E+00 2.5299E-02 7.4000E+00 1.1860E+00 2.5618E-02 # Data No.3 2.2500E-02 1.3310E+00 3.4606E-02 2.7500E-02 1.3370E+00 2.4066E-02 3.5000E-02 1.3440E+00 2.6880E-02 .... 1.8936E+01 1.0080E+00 2.9232E-02 2.0064E+01 9.6300E-01 2.9853E-02 2.1296E+01 1.0310E+00 3.1961E-02 Plot Data Those three experimental data sets can be approximated by y = To plot data with error bars, use with yerrorbars . This gnuplot> plot "plotexp.dat" index 0:0 using 1:2:3 with yerrorbars, > "plotexp.dat" index 1:1 using 1:2:3 with yerrorbars, > "plotexp.dat" index 2:2 using 1:2:3 with yerrorbars ![]() When your command line is too long, put “\” at the end of line, Make a Legend Each experimental data set was measured by three different gnuplot> plot "plotexp.dat" ind 0:0 usi 1:2:3 ti "A. Smith (1992)" w yerr, > "plotexp.dat" ind 1:1 usi 1:2:3 ti "B. Smith (1993)" w yerr, > "plotexp.dat" ind 2:2 usi 1:2:3 ti "C. Smith (1999)" w yerr ![]() Draw a Calculated Line To overlay a function and experimental data, the fitted linear gnuplot> f(x)= -0.01687*x + 1.3512 gnuplot> plot f(x) with lines, > "plotexp.dat" ind 0:0 usi 1:2:3 ti "A. Smith (1992)" w yerr, > "plotexp.dat" ind 1:1 usi 1:2:3 ti "B. Smith (1993)" w yerr, > "plotexp.dat" ind 2:2 usi 1:2:3 ti "C. Smith (1999)" w yerr ![]() In the above case, color number used for each measurement is Change the Line Style Those experimental data are distinguishable by colors when ![]() I suppose nobody likes such a funny symbol. Let’s define all the gnuplot> set linestyle 1 lt 1 lw 3 gnuplot> set linestyle 2 lt 1 pt 7 gnuplot> set linestyle 3 lt 1 pt 8 gnuplot> set linestyle 4 lt 1 pt 9 If your gnuplot is newer than ver.3.8: gnuplot> set style line 1 lt 1 lw 3 gnuplot> set style line 2 lt 1 pt 7 gnuplot> set style line 3 lt 1 pt 8 gnuplot> set style line 4 lt 1 pt 9 The first line defines the linestyle No.1 as the solid line with gnuplot> f(x)= -0.01687*x + 1.3512 gnuplot> plot f(x) notitle with lines linestyle 1, > "plotexp.dat" ind 0:0 usi 1:2:3 ti "A. Smith (1992)" w yerr linestyle 2, > "plotexp.dat" ind 1:1 usi 1:2:3 ti "B. Smith (1993)" w yerr linestyle 3, > "plotexp.dat" ind 2:2 usi 1:2:3 ti "C. Smith (1999)" w yerr linestyle 4 ![]() Insert Axis Names In the above graph, a legend for the fitted line was removed with Now, make labels for the X and Y axes. The name of X axis is gnuplot> set xlabel "Energy [MeV]" gnuplot> set ylabel "Cross Section [b]" gnuplot> replot ![]() Adjust the Range Then, adjust the ranges for X and Y axes. For Y axis, setting the gnuplot> set xrange [0.01:20] gnuplot> set yrange [0:2] gnuplot> set logscale x gnuplot> replot ![]() Put Graduations Finally, put graduations on the axes. The X axis is log, so you can gnuplot> set ytics 1 gnuplot> set mytics 10 gnuplot> set grid gnuplot> replot ![]() Generate a Postscript File Now we have completed. With the Postscript driver, specify an gnuplot> set term postscript gnuplot> set output "plotexp.ps" gnuplot> replot gnuplot> save "plotexp.plt" gnuplot> quit A Postscript printer can generate a printed graph. Postscript ![]() It is not clear to see because the image size is small. Anyway,
|