1 | For example your data file, force.dat , might look like: |
---|
2 | |
---|
3 | # This file is called force.dat |
---|
4 | # Force-Deflection data for a beam and a bar |
---|
5 | # Deflection Col-Force Beam-Force |
---|
6 | 0.000 0 0 |
---|
7 | 0.001 104 51 |
---|
8 | 0.002 202 101 |
---|
9 | 0.003 298 148 |
---|
10 | 0.0031 290 149 |
---|
11 | 0.004 289 201 |
---|
12 | 0.0041 291 209 |
---|
13 | 0.005 310 250 |
---|
14 | 0.010 311 260 |
---|
15 | 0.020 280 240 |
---|
16 | |
---|
17 | You can display your data by typing: |
---|
18 | |
---|
19 | gnuplot> plot "force.dat" using 1:2 title 'Column', \ |
---|
20 | "force.dat" using 1:3 title 'Beam' |
---|
21 | Customization of the axis ranges, axis labels, and plot title, as well as many other features, are specified using the set command. Specific examples of the set command follow. (The numerical values used in these examples are arbitrary.) To view your changes type: replot at the gnuplot> prompt at any time. |
---|
22 | |
---|
23 | Create a title: > set title "Force-Deflection Data" |
---|
24 | Put a label on the x-axis: > set xlabel "Deflection (meters)" |
---|
25 | Put a label on the y-axis: > set ylabel "Force (kN)" |
---|
26 | Change the x-axis range: > set xrange [0.001:0.005] |
---|
27 | Change the y-axis range: > set yrange [20:500] |
---|
28 | Have Gnuplot determine ranges: > set autoscale |
---|
29 | Move the key: > set key 0.01,100 |
---|
30 | Delete the key: > unset key |
---|
31 | Put a label on the plot: > set label "yield point" at 0.003, 260 |
---|
32 | Remove all labels: > unset label |
---|
33 | Plot using log-axes: > set logscale |
---|
34 | Plot using log-axes on y-axis: > unset logscale; set logscale y |
---|
35 | Change the tic-marks: > set xtics (0.002,0.004,0.006,0.008) |
---|
36 | Return to the default tics: > unset xtics; set xtics auto |
---|
37 | |
---|
38 | Other features which may be customized using the set command are: arrow, border, clip, contour, grid, mapping, polar, surf |
---|
39 | |
---|
40 | Sometimes, several commands are typed to create a particular plot, and it is easy to make a typographical error when entering a command. To stream- line your plotting operations, several Gnuplot commands may be combined into a single script file. For example, the following file will create a customized display of the force-deflection data: |
---|
41 | |
---|
42 | # Gnuplot script file for plotting data in file "force.dat" |
---|
43 | # This file is called force.p |
---|
44 | set autoscale # scale axes automatically |
---|
45 | unset log # remove any log-scaling |
---|
46 | unset label # remove any previous labels |
---|
47 | set xtic auto # set xtics automatically |
---|
48 | set ytic auto # set ytics automatically |
---|
49 | set title "Force Deflection Data for a Beam and a Column" |
---|
50 | set xlabel "Deflection (meters)" |
---|
51 | set ylabel "Force (kN)" |
---|
52 | set key 0.01,100 |
---|
53 | set label "Yield Point" at 0.003,260 |
---|
54 | set arrow from 0.0028,250 to 0.003,280 |
---|
55 | set xr [0.0:0.022] |
---|
56 | set yr [0:325] |
---|
57 | plot "force.dat" using 1:2 title 'Column' with linespoints , \ |
---|
58 | "force.dat" using 1:3 title 'Beam' with points |
---|
59 | |
---|
60 | Then the total plot can be generated with the command: gnuplot> load 'force.p' |
---|
61 | |
---|
62 | |
---|