#### Overview of this book

gnuplot is the world's finest technical plotting software, used by scientists, engineers, and others for many years. It is in constant development and runs on practically every operating system, and can produce output in almost any format. The quality of its 3d plots is unmatched and its ability to be incorporated into computer programs and document preparation systems is excellent. gnuplot Cookbook ñ it will help you master gnuplot. Start using gnuplot immediately to solve your problems in data analysis and presentation. Quickly find a visual example of the graph you want to make and see a complete, working script for producing it. Learn how to use the new features in gnuplot 4.4. Find clearly explained, working examples of using gnuplot with LaTeX and with your own computer programming language. You will master all the ins and outs of gnuplot through gnuplot Cookbook. You will learn to plot basic 2d to complex 3d plots, annotate from simple labels to equations, integrate from simple scripts to full documents and computer progams. You will be taught to annotate graphs with equations and symbols that match the style of the rest of your text, thus creating a seamless, professional document. You will be guided to create a web page with an interactive graph, and add graphical output to your simulation or numerical analysis program. Start using all of gnuplot's simple to complex features to suit your needs, without studying its 200 page manual through this Cookbook.
gnuplot Cookbook
Credits
www.PacktPub.com
Preface
Free Chapter
Plotting Curves, Boxes, Points, and more
Annotating with Labels and Legends
Applying Colors and Styles
Combining Multiple Plots
Programming gnuplot and Dealing with Data
The Third Dimension
Using and Making Graphical User Interfaces
Surveying Special Topics
Finding Help and Information
Index

## Combining contours and images

Sometimes we would like to plot two related but different sets of data on the same graph. In the case of 2D plots, it's simple: we just plot any number of curves and identify them with labels or a legend. But with 3D plots, trying to interpret a graph containing two different surfaces or sets of contours would be difficult, and plotting two heat maps simultaneously would not make any sense.

The previous figure shows one way to do this: plot contours and an image map together.

### How to do it…

Feed this code to gnuplot to get the previous figure:

```set xrange [0:pi]
set yrange [0:pi]
set iso 100
set samp 100
set cntrparam levels 10
unset key
unset surface
set view map
set contour base
set pm3d at b
splot '++' using 1:2:(\$1**2-\$2**2):(sin(\$1**2+\$2**2))\
with lines lw 2```

### How it works…

We set everything up as in the previous contour plot example, but we also put in a `set pm3d at base`, so we are asking for both a contour plot and a colored surface plot. How do we make...