Gnuplot OLD

From Script | Spoken-Tutorial
Revision as of 17:51, 11 December 2012 by Minal (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Gnuplot is a portable command-line driven graphing utility for Linux, OS/2, MS Windows, OSX, VMS, and many other platforms. The source code is copyrighted but freely distributed (i.e., you don’t have to pay for it). It was originally created to allow scientists and students to visualize mathematical functions and data interactively, but has grown to support many non-interactive uses such as web scripting. It is also used as a plotting engine by third-party applications like Octave. Gnuplot has been supported and under active development since 1986.

Gnuplot supports many types of plots in either 2D and 3D. It can draw using lines, points, boxes, contours, vector fields, surfaces, and various associated text. It also supports various specialized plot types.

Gnuplot supports many different types of output: interactive screen terminals (with mouse and hotkey input), direct output to pen plotters or modern printers, and output to many file formats (eps, fig, jpeg, LaTeX, metafont, pbm, pdf, png, postscript, svg, ...). Gnuplot is easily extensible to include new output modes. Recent additions include interactive terminals based on aquaterm (OSX) and wxWidgets (multiple platforms).

This set of tutorials will cover features and usage of Gnuplot version 4.4. Please see the associated text box of individual spoken tutorials on the website to decide the versions of Gnuplot and OS to which it is applicable.

The Spoken Tutorial Effort for Gnuplot is being contributed by Srishti Sethi from Engineering College Bikaner (India) http://srishtisethi.blogspot.com.

Gnuplot Slide Template                                                                                                                               Glossary

Installation & Starting

Check to see if you already have Gnuplot, by typing 'which gnuplot' in a shell window. If Gnuplot is installed, you need to make sure that it is version 4.0 or newer ('gnuplot --version').If you need to download Gnuplot go to http://www.gnuplot.info/ If you are using Debian Linux, Gnuplot will be downloaded and installed if you issue the following command as root: 'apt-get install gnuplot'. On Unix, Linux and OS X systems start Gnuplot by simply opening a terminal and typing:

gnuplot  


Basic Usage

  • For numerical calculation
  • For experimental data
  • Plotting functions
  • Weather situation — daily rain falls and climate maps provided by NASA.
  • Online weather conditions observed at the NCAR Foothills Laboratory.
  • Interactive form interface to X-ray scattering calculations
  • For Wireless Detection and Tracking.

Features

  • Internationalization
  • Transparency
  • Volatile data
  • New plot elements
  • New smoothing algorithms
  • New or revised terminal drivers
  • Canvas size

Command Syntax

  • gnuplot commands are case sensitive.
  • strings are indicated with quotes “ “.
  • mulitple commands on same line are separated by semicolons.
  • cannot break command onto multiple lines.

Plotting Commands

  • plot – generates 2D plots | operates in rectangular or polar coordinates.
  • splot – generates 3D plots | plot surfaces, countours, points and/or lines.
  • replot – appends its arguments to previous plot or splot.

plot {<ranges>}{<function> | {"<datafile>" {datafile-modifiers}}}{axes <axes>} {<title-spec>} {with <style>}{, {definitions,} <function> ...}

Basic 2D Plot

  • Setting title : set title {"<title-text>"} {<xoff>}{,<yoff>} {"{,<size>}"}

Ex : set title "Force Deflection Data \n and curve fit"

  • Setting Key : set key {on|off} {default}

{left | right | top | bottom | outside | below | <position>} {Left | Right} {{no}reverse} {samplen <sample_length>} {spacing <vertical_spacing>} {width <width_increment>} {height <height_increment>} {{no}autotitles} {title "<text>"} {{no}enhanced} {{no}box { {linestyle | ls <line_style>} | {linetype | lt <line_type>} {linewidth | lw <line_width>}}} Ex : set key left box

  • Setting tics (xtics,ytics,ztics) : set xtics {axis | border} {{no}mirror} {{no}rotate {by <ang>}}

{ autofreq | <incr> | <start>, <incr> {,<end>} | ({"<label>"} <pos> {<level>} {,{"<label>"}...) } { font "name{,<size>}" } { textcolor <colorspec> }
Ex : set xtics 0, 10, 40
set ytics 1500, 200, 1900

  • Setting axis labels:set xlabel {‘‘<label>’’} {<xoff>}{,<yoff>} {font ‘‘{,size>}’’}

Ex : set xlabel "Distance (AU)" font "Helvetica,24"

  • Setting arbitrary label : set label {<tag>} { {"<label text>"{,<value>}} {, ...}} }

{at <position>} {left | center | right} {norotate | rotate {by <degrees>}} {font "<name>{,<size>}"} {front | back} {textcolor <colorspec>} {point <pointstyle> {offset x, y} | nopoint}
Ex : set label "dependence cost" at 25, 1650 rotate by 52 tc lt 1
set label "3.52" at 3.52,-1.65 center font "Helvetica,22"

  • Plotting various functions : Gnuplot supports various functions.Check here

Ex : plot sin(x)

Contributors and Content Editors

Minal, Nancyvarkey