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

## Plotting with polar coordinates

All the plots in this chapter up to now have implicitly used rectangular coordinates, usually denoted as x and y. For certain types of information, however, polar geometry is the natural coordinate system. In polar coordinates we have a radius, `r`, measured from the origin, usually at the center of the graph, and an angle, `θ`, usually measured counter-clockwise from the horizontal. On the gnuplot command line, the angular coordinate is called `t` by default. The following is an example of a spiral illustration:

Using polar coordinates we can plot spirals and closed curves that are impossible to define explicitly using rectangular coordinates.

### How to do it…

Following is an example of how to use polar coordinates to get the spiral shown in the previous illustration:

```set xtics axis nomirror
set ytics axis nomirror
set zeroaxis
unset border
set samples 500
set polar
plot [0:12*pi] t```

### How it works…

The first three lines create a pair of axes that intersect at the origin in the center of the graph. This works for polar plots too, where we are measuring the radius from the center. The `unset border` line removes the frame that has served up to now as axes for our rectangular coordinate plots. Next, we increase the number of samples for a smooth plot. The crucial, highlighted line `set polar` changes to polar (r-θ) coordinates from the default rectangular (x-y). In the plot command, `t` is now a dummy variable that passes through the given angular range (default [0:2*pi], changed to [0:12*pi] here), and the provided function (`r)` is a function of `t`, in this case the identity, that yields a circular spiral.