Some usefull Gnuplot commands ================================= Gnuplot is a free tool for plotting graphs and data sets and since the late 80s well-established in the scientific community for many different plotting applications. You can obtain it under http://www.gnuplot.info for Windows, Linux and MacOS. Gnuplot uses a simple scripting syntax and can be interactively used via a terminal. The plots appear in a primitve viewer window which supports simple mouse interaction. Here are some use cases: - Plot function graphs - Plot parametrized functions - Plot data sets, probably interpolated - ...and much more. You may want to check the demo section under http://www.gnuplot.info/screenshots/index.html#demos Here are some useful commands. You may type them in this order in the gnuplot terminal and see what happens. Hint: If you want to save a sequence of gnuplot commands as a script just create an ordinary text file in your text editor of choice and save it as "my_script.plt" (actually the file ending has no influence) In gnuplot you may then run your script by typing load "path/to/my/script/my_script.plt" ------------------------------------------------------ # Define a real function of one variable f(x) = x**2 # Set sample density to produce smoother plots set samples 500 # Plot the function plot f(x) # Define another function. # Note: the placeholder variable does not need to be x g(t) = t**3 # Plot both functions. # Note: the plot command needs to be invoked with x for 1d plotting though, # in contrast to the defined functions plot f(x), g(x) # Define some line styles for later use # Line type (lt) is solid line # Line width (lw) should be 3 set style line 1 lt 1 lw 3 linecolor rgb "red" set style line 2 lt 1 lw 3 linecolor rgb "blue" # Plot the functions with our new line styles plot f(x) ls 1, g(x) ls 2 # Define a function of two arguments h(x,y) = x*y**2 # Plot the (surface) graph of h using the second line style. splot h(x,y) ls 2 # Now plot a parametrized curve in the plane. So let's switch to parametric mode: set parametric # Plot a parametrized circle using first line style plot [0:6.28] cos(t), sin(t) ls 1 # Change the title set title "My Curve Plot" # Save plot to an SVG-file # other relevant file formats are "png" and "postscript" # First set output stream to file format set terminal svg # Set output name set output "my_plot.svg" # Plot to current output stream (now SVG) replot # Reset output stream to wxt window set terminal wxt # The next plot should open a window again replot # Reset everything reset