TABLE OF CONTENTS


72-plotting

DESCRIPTION

This example shows how to make 2D and 3D plots with PWTK.

In this example, we plot functions but datafiles can also be plotted -- the usage is completely analogous.

BEWARE

PWTK uses Gnuplot ( http://www.gnuplot.info/ ) for plottiong, which is required to run this example.

EXAMPLE SOURCE FILE

plotting.pwtk

SOURCE

# a 1D function or a file containing e.g. "x f(x)" columns can be
# plotted with ::pwtk::plot

plot sin(x)

# ::pwtk::plot command is configurable and more than one function can be specified

plot \
    -xr -pi:pi -yr -1.1:1.1 \
    -xl x      -yl "sin(x) and cos(x)" \
    -xf %.1f   -yf %.1f \
    sin(x) cos(x)


# Multiplots are plotted with ::pwtk::multiplot. Let's plot a 4-plot
# multiplot with the first three plots showing a single function,
# whereas the last plot shows all the three functions together

multiplot \
    -xr -pi:pi -yr -1.1:1.1 \
    -xl x      -yl f(x) \
    -xf %.1f   -yf %.1f \
    sin(x) cos(x) tan(x) { sin(x) cos(x) tan(x) }


# heatmaps can be created with ::pwtk::heatmap

heatmap -xr -pi:pi  -yr -pi:pi  -xl x  -yl y  sin(x)*cos(y)

# different color palatte can be used (see ::pwtk::heatmap)

heatmap -pal rainbow -xr -pi:pi  -yr -pi:pi  -xl x  -yl y  sin(x)*cos(y)

# palette can also be inverted

heatmap -pal {rainbow negative} -xr -pi:pi  -yr -pi:pi  -xl x  -yl y  sin(x)*cos(y)


# surface plots can be created with ::pwtk::splot

splot -pal STM  -xr -pi:pi  -yr -pi:pi  -zr -1.1:1.1  -zf %.1f \
    -xl "x"  -yl "y"  -zl "sin(x)*cos(y)" -x {set zlabel rotate by 90} sin(x)*cos(y)