## Contents

# 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:

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:

gnuplot> call "example2.in"

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:

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/