How can I make a batch file with a series of commandos for Gnuplot, and then execute it in Gnuplot? For example: defining a function, setting the x- and y-axis settings, setting an output so when I run Gnuplot and execute this file, I immediately got my graph. Thanks for reading in advance.
1 Answer
Below is an excerpt from http://people.duke.edu/~hpgavin/gnuplot.html:
6. SCRIPT FILES
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:
# Gnuplot script file for plotting data in file "force.dat" # This file is called force.p set autoscale # scale axes automatically unset log # remove any log-scaling unset label # remove any previous labels set xtic auto # set xtics automatically set ytic auto # set ytics automatically set title "Force Deflection Data for a Beam and a Column" set xlabel "Deflection (meters)" set ylabel "Force (kN)" set key 0.01,100 set label "Yield Point" at 0.003,260 set arrow from 0.0028,250 to 0.003,280 set xr [0.0:0.022] set yr [0:325] plot "force.dat" using 1:2 title 'Column' with linespoints , \ "force.dat" using 1:3 title 'Beam' with points
Then the total plot can be generated with the command:
gnuplot> load 'force.p'
The file force.dat
looks something like:
# This file is called force.dat
# Force-Deflection data for a beam and a bar
# Deflection Col-Force Beam-Force
0.000 0 0
0.001 104 51
0.002 202 101
0.003 298 148
0.0031 290 149
0.004 289 201
0.0041 291 209
0.005 310 250
0.010 311 260
0.020 280 240
Please look at the source for further information and a much better explanation.