Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
labs:gnuplot [2011/05/01 21:40] – created admin | labs:gnuplot [2011/05/01 21:49] (current) – [Data Files] admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Gnuplot ====== | ====== Gnuplot ====== | ||
+ | |||
+ | |||
+ | ===== Data Files ===== | ||
+ | |||
+ | A typical Gnuplot data file consists of lines of text, where each line has two numbers, representing an x-value and a y-value. Here is a Gnuplot data file called " | ||
+ | |||
+ | # number of days in each month of 2010 | ||
+ | 1 31 | ||
+ | 2 28 | ||
+ | 3 31 | ||
+ | 4 30 | ||
+ | 5 31 | ||
+ | 6 30 | ||
+ | 7 31 | ||
+ | 8 31 | ||
+ | 9 30 | ||
+ | 10 31 | ||
+ | 11 30 | ||
+ | 12 31 | ||
+ | |||
+ | **Explanation: | ||
+ | |||
+ | The first line, the one starting with #, is a comment. | ||
+ | |||
+ | Gnuplot will plot bars of size " | ||
+ | |||
+ | ===== Plot Files ===== | ||
+ | |||
+ | To plot the " | ||
+ | |||
+ | set terminal png large | ||
+ | # Modify to change the output file | ||
+ | set output " | ||
+ | set data style boxes | ||
+ | set boxwidth 0.4 | ||
+ | set xtics nomirror | ||
+ | set border 11 | ||
+ | | ||
+ | # Modify this code to set the x-range | ||
+ | set xrange [0:13] | ||
+ | | ||
+ | # Modify this line to set the y-range | ||
+ | set yrange [0:32] | ||
+ | | ||
+ | set xlabel " | ||
+ | set ylabel "Days in Month" | ||
+ | |||
+ | set xtics (" | ||
+ | " | ||
+ | |||
+ | set key below | ||
+ | | ||
+ | plot ' | ||
+ | |||
+ | |||
+ | ===== Executing Gnuplot ===== | ||
+ | |||
+ | To execute Gnuplot, in the terminal run gnuplot < | ||
+ | |||
+ | For the above example, you would execute | ||
+ | |||
+ | gnuplot bars.plot | ||
+ | |||
+ | There should be no output (gnuplot is a bad parent), but you should now see the output file in the directory if you run ls. | ||
+ | |||
+ | To create your own graph file, you will probably need to modify | ||
+ | |||
+ | * the output file's name | ||
+ | * the input file's name | ||
+ | * the x-axis | ||
+ | * y-axis range and labels | ||
+ | * the xtics (x-axis labels). |