From Documentation
Jump to: navigation, search
m (Set up)
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Template:LegacyPage}}
 
{{Software
 
|package_name=GNUPLOT
 
|package_description=Portable command-line driven graphing utility.
 
|package_idnumber=113
 
}}
 
 
 
 
=Introduction=
 
=Introduction=
 
Gnuplot is a command-line driven graphing utility that is copyrighted but freely distributed. Designed for efficient and interactive visualization of mathematical functions and data. It has the capacity for generating publication quality figures of 2 or 3 dimensions composed of lines, points, boxes, contours, vector fields, surfaces and texts.
 
Gnuplot is a command-line driven graphing utility that is copyrighted but freely distributed. Designed for efficient and interactive visualization of mathematical functions and data. It has the capacity for generating publication quality figures of 2 or 3 dimensions composed of lines, points, boxes, contours, vector fields, surfaces and texts.
  
=Version Selection=
+
=Versions=
Gnuplot is installed on most SHARCNET systems as part of the operating systems default software stack for instance /usr/bin/gnuplot. A more recent version can be accessed on certain systems shown in the Availability Table ([https://www.sharcnet.ca/my/software/show/113 Gnuplot] portal page] by loading the sharcnet module as follows:
+
Gnuplot is installed on most Compute Canada/SHARCNET systems as part of the default software stack.
<pre>
+
 
module load gnuplot/4.4.3
+
To see the latest versions available, run:
</pre>
+
 
 +
module avail gnuplot
 +
 
 +
and then load the desired modules.
  
 
=Example plots=
 
=Example plots=
  
 
==Set up==
 
==Set up==
The following examples can be run on SHARCNet system development nodes. For instance, in order to run these examples on an Orca development node the following steps should be followed:
+
The following examples can be run Compute Canada systems.
  
 
*Login to the system enabling X11 forwarding with the -Y option to ssh:
 
*Login to the system enabling X11 forwarding with the -Y option to ssh:
bucanl-jad@bucanl-bonx8:~$ ssh -Y jdesjard@orca.sharcnet.ca
+
    $ ssh -Y your_username_here@graham.computecanada.ca
 
   
 
   
Welcome to the SHARCNET cluster Orca.
+
*Then launch the program:
+
<source lang="bash">
Please see the following URLs for status of this and other clusters:
+
$ gnuplot
https://www.sharcnet.ca/help/index.php/Orca
+
https://www.sharcnet.ca/my/systems
+
+
*****
+
  
*Then login to a development node using the -Y option to ssh again:
+
G N U P L O T
[jdesjard@orc-login1:~] ssh -Y orc-dev1
+
Version 5.0 patchlevel 3    last modified 2016-02-21
Last login: Fri Dec  4 10:05:53 2015 from orc-login2.orca.sharcnet
+
 
+
Copyright (C) 1986-1993, 1998, 2004, 2007-2016
Welcome to the SHARCNET cluster Orca.
+
Thomas Williams, Colin Kelley and many others
+
Please see the following URLs for status of this and other clusters:
+
https://www.sharcnet.ca/help/index.php/Orca
+
https://www.sharcnet.ca/my/systems
+
+
*****
+
  
*Next load the GNUPlot module:
+
gnuplot home:     http://www.gnuplot.info
  module load gnuplot/4.4.3
+
faq, bugs, etc:  type "help FAQ"
 +
immediate help:  type "help" (plot window: hit 'h')
 +
 
 +
Terminal type set to 'x11'
 +
gnuplot>
 +
 
 +
</source>
  
*Then launch the program:
 
[jdesjard@orc129:~] gnuplot
 
 
G N U P L O T
 
Version 4.4 patchlevel 3
 
last modified March 2011
 
System: Linux 2.6.32-358.18.1.el6.x86_64
 
 
Copyright (C) 1986-1993, 1998, 2004, 2007-2010
 
Thomas Williams, Colin Kelley and many others
 
 
gnuplot home:    http://www.gnuplot.info
 
faq, bugs, etc:  type "help seeking-assistance"
 
immediate help:  type "help"
 
plot window:      hit 'h'
 
 
Terminal type set to 'x11'
 
gnuplot>
 
  
 
Once that "gnuplot>" prompt is in the terminal (that is set to 'X11') the following examples can be pasted to generate the example figures.
 
Once that "gnuplot>" prompt is in the terminal (that is set to 'X11') the following examples can be pasted to generate the example figures.
  
 
==Example 1: multiple axis scaling==
 
==Example 1: multiple axis scaling==
 +
 +
Put the code below into a file called ''example1.in''
 
<pre>
 
<pre>
[jdesjard@bul128:~]  cat /home/jdesjard/gnuplot/example1.in
 
#
 
# $Id: multiaxis.dem,v 1.1 2007/06/09 22:10:45 sfeam Exp $
 
#
 
 
 
# Use the 3rd plot of the electronics demo to show off
 
# Use the 3rd plot of the electronics demo to show off
 
# the use of multiple x and y axes in the same plot.
 
# the use of multiple x and y axes in the same plot.
Line 99: Line 69:
 
set autoscale y2
 
set autoscale y2
 
plot abs(A(jw)) axes x1y1, 180./pi*arg(A(jw)) axes x2y2
 
plot abs(A(jw)) axes x1y1, 180./pi*arg(A(jw)) axes x2y2
[jdesjard@bul128:~]
 
 
</pre>
 
</pre>
 
Call the script in gnuplot to generate the figure as follows:
 
Call the script in gnuplot to generate the figure as follows:
Line 106: Line 75:
  
 
<pre>
 
<pre>
gnuplot> call "/home/jdesjard/gnuplot/example1.in"
+
gnuplot> call "example1.in"
 
   
 
   
 
   
 
   
Line 124: Line 93:
  
 
==Example 2: 3D surface==
 
==Example 2: 3D surface==
 +
Put the code below into a file called ''example2.in''
 +
 
<pre>
 
<pre>
[jdesjard@bul128:~]  cat /home/jdesjard/gnuplot/example2.in
 
#
 
# $Id: surface1.dem,v 1.11 2004/09/17 05:01:12 sfeam Exp $
 
#
 
 
set samples 21
 
set samples 21
 
set isosample 11
 
set isosample 11
Line 143: Line 110:
 
set yrange [-10:10]
 
set yrange [-10:10]
 
splot x*y
 
splot x*y
[jdesjard@bul128:~]
 
 
</pre>
 
</pre>
  
Line 151: Line 117:
  
 
<pre>
 
<pre>
gnuplot> call "/home/jdesjard/gnuplot/example2.in"
+
gnuplot> call "example2.in"
 
   
 
   
 
   
 
   
Line 169: Line 135:
  
 
==Example 3: 3D hidden surfaces==
 
==Example 3: 3D hidden surfaces==
 +
Put the code below into a file called ''example3.in''
 +
 
<pre>
 
<pre>
[jdesjard@bul128:~] cat /home/jdesjard/gnuplot/example3.in
 
#
 
 
# Another example of pm3d hidden surface removal,
 
# Another example of pm3d hidden surface removal,
 
# this time using pm3d depth-ordering
 
# this time using pm3d depth-ordering
Line 210: Line 176:
  
 
unset multiplot
 
unset multiplot
[jdesjard@bul128:~]
 
 
</pre>
 
</pre>
  
Line 218: Line 183:
  
 
<pre>
 
<pre>
gnuplot> call "/home/jdesjard/gnuplot/example3.in"
+
gnuplot> call "example3.in"
 
   
 
   
 
   
 
   
Line 234: Line 199:
 
   
 
   
 
</pre>
 
</pre>
 
=General Notes=
 
{{NeedsGraphics}}
 
==Visualization systems==
 
For information regarding graphics resources follow the links from the [https://www.sharcnet.ca/help/index.php/Visualization Visualization] page.
 
  
 
=References=
 
=References=
Line 250: Line 210:
 
o Demo Scripts for gnuplot version 5<br>
 
o Demo Scripts for gnuplot version 5<br>
 
http://www.gnuplot.info/demo/
 
http://www.gnuplot.info/demo/
 +
 +
[[Category:Tutorials]]

Latest revision as of 16:23, 9 May 2019

Introduction

Gnuplot is a command-line driven graphing utility that is copyrighted but freely distributed. Designed for efficient and interactive visualization of mathematical functions and data. It has the capacity for generating publication quality figures of 2 or 3 dimensions composed of lines, points, boxes, contours, vector fields, surfaces and texts.

Versions

Gnuplot is installed on most Compute Canada/SHARCNET systems as part of the default software stack.

To see the latest versions available, run:

module avail gnuplot

and then load the desired modules.

Example plots

Set up

The following examples can be run Compute Canada systems.

  • Login to the system enabling X11 forwarding with the -Y option to ssh:
   $ ssh -Y your_username_here@graham.computecanada.ca

  • Then launch the program:
$ gnuplot
 
	G N U P L O T
	Version 5.0 patchlevel 3    last modified 2016-02-21
 
	Copyright (C) 1986-1993, 1998, 2004, 2007-2016
	Thomas Williams, Colin Kelley and many others
 
	gnuplot home:     http://www.gnuplot.info
	faq, bugs, etc:   type "help FAQ"
	immediate help:   type "help"  (plot window: hit 'h')
 
Terminal type set to 'x11'
gnuplot>


Once that "gnuplot>" prompt is in the terminal (that is set to 'X11') the following examples can be pasted to generate the example figures.

Example 1: multiple axis scaling

Put the code below into a file called example1.in

# Use the 3rd plot of the electronics demo to show off
# the use of multiple x and y axes in the same plot.
# 
A(jw) = ({0,1}*jw/({0,1}*jw+p1)) * (1/(1+{0,1}*jw/p2))
p1 = 10
p2 = 10000
set dummy jw
set grid x y2
set key center top title " "
set logscale xy
set log x2
unset log y2
set title "Transistor Amplitude and Phase Frequency Response"
set xlabel "jw (radians)"
set xrange [1.1 : 90000.0]
set x2range [1.1 : 90000.0]
set ylabel "magnitude of A(jw)"
set y2label "Phase of A(jw) (degrees)"
set ytics nomirror
set y2tics
set tics out
set autoscale  y
set autoscale y2
plot abs(A(jw)) axes x1y1, 180./pi*arg(A(jw)) axes x2y2

Call the script in gnuplot to generate the figure as follows:

figure resulting from demo commands
Figure produced on orc-dev# with commands from "multiple axis scales" at [gnuplot examples]
gnuplot> call "example1.in"
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Example 2: 3D surface

Put the code below into a file called example2.in

set samples 21
set isosample 11
set xlabel "X axis" offset -3,-2
set ylabel "Y axis" offset 3,-2
set zlabel "Z axis" offset -5
set title "3D gnuplot demo"
set label 1 "This is the surface boundary" at -10,-5,150 center
set arrow 1 from -10,-5,120 to -10,0,0 nohead
set arrow 2 from -10,-5,120 to 10,0,0 nohead
set arrow 3 from -10,-5,120 to 0,10,0 nohead
set arrow 4 from -10,-5,120 to 0,-10,0 nohead
set xrange [-10:10]
set yrange [-10:10]
splot x*y

Call the script in gnuplot to generate the figure as follows:

figure resulting from demo commands
Figure produced on orc-dev# with commands from "surfaces 1" at [gnuplot examples]
gnuplot> call "example2.in"
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Example 3: 3D hidden surfaces

Put the code below into a file called example3.in

# Another example of pm3d hidden surface removal,
# this time using pm3d depth-ordering
#
set multiplot title "Interlocking Tori"
set title "PM3D surface\nno depth sorting"

set parametric
set urange [-pi:pi]
set vrange [-pi:pi]
set isosamples 50,20

set origin -0.02,0.0
set size 0.55, 0.9

unset key
unset xtics
unset ytics
unset ztics
set border 0
set view 60, 30, 1.5, 0.9
unset colorbox

set pm3d scansbackward
splot cos(u)+.5*cos(u)*cos(v),sin(u)+.5*sin(u)*cos(v),.5*sin(v) with pm3d, \
      1+cos(u)+.5*cos(u)*cos(v),.5*sin(v),sin(u)+.5*sin(u)*cos(v) with pm3d

set title "PM3D surface\ndepth sorting"

set origin 0.40,0.0
set size 0.55, 0.9
set colorbox vertical user origin 0.9, 0.15 size 0.02, 0.50
set format cb "%.1f"

set pm3d depthorder
splot cos(u)+.5*cos(u)*cos(v),sin(u)+.5*sin(u)*cos(v),.5*sin(v) with pm3d, \
      1+cos(u)+.5*cos(u)*cos(v),.5*sin(v),sin(u)+.5*sin(u)*cos(v) with pm3d

unset multiplot

Call the script in gnuplot to generate the figure as follows:

figure resulting from demo commands
Figure produced on orc-dev# with commands from "pm3d hidden surfaces" at [gnuplot examples]
gnuplot> call "example3.in"
 
 
 
 
 
 
 
 
 
 
 
 
 
 

References

o Online Documentation
http://www.gnuplot.info/documentation.html

o A brief gnuplot tutorial by Henri Gavin
http://people.duke.edu/~hpgavin/gnuplot.html

o Demo Scripts for gnuplot version 5
http://www.gnuplot.info/demo/