Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
gnuplot Cookbook

You're reading from   gnuplot Cookbook Visual guide to every kind of graph you can make with this plotting software with this book and ebook

Arrow left icon
Product type Paperback
Published in Feb 2012
Publisher Packt
ISBN-13 9781849517249
Length 220 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Lee Phillips Lee Phillips
Author Profile Icon Lee Phillips
Lee Phillips
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

gnuplot Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Plotting Curves, Boxes, Points, and more FREE CHAPTER 2. Annotating with Labels and Legends 3. Applying Colors and Styles 4. Controlling your Tics 5. Combining Multiple Plots 6. Including Plots in Documents 7. Programming gnuplot and Dealing with Data 8. The Third Dimension 9. Using and Making Graphical User Interfaces 10. Surveying Special Topics Finding Help and Information
Index

Making a scatterplot


If you are in possession of a collection of measurements that, as is usually the case, is subject to random errors, an attempt to simply plot a curve through the measurements may result in a chaotic graph that will be difficult to interpret. In these cases, one usually begins with a scatterplot, which is simply a plot of a dot or small symbol at each data point. An examination of such a plot often leads to the discovery of correlations or patterns.

Getting ready

To make this recipe interesting, we need some slightly random-looking data. You may have some available, in which case you merely need to ensure that it is in a format that gnuplot can read. Simply arrange the data so that each line of the file contains one data point with space-separated x and y values:

x1 y1
x2 y2
...

Then name the file scatter.dat.

If you don't have such a file of your own handy, use the one called scatter.dat that we have provided. Make sure that the file is in the directory in which you have started gnuplot, so that the program can find it.

How to do it…

Tip

Some of the recipes in this book will not work as intended if entered in the same interactive session unless you give the reset command first. This is because these scripts make settings that change gnuplot's default behavior.

Now simply tell gnuplot:

plot 'scatter.dat' with points pt 7

If you are using the file we provided, you will get a plot similar to the one shown in the previous figure.

There's more…

You can plot the points using different symbols. Try plot 'scatter.dat' with dots to get the smallest dot available to your terminal. For use with scatterplots of very large datasets, try the following command:

plot 'scatter.dat' with points pt n

With different integers for n. pt stands for pointtype, and the different pointtypes available are dependent on your terminal. Simply type test in gnuplot to see a demonstration of all the pointtypes available for the currently selected terminal. You can find more about point and line styles in Chapter 3, Applying Colors and Styles.

You have been reading a chapter from
gnuplot Cookbook
Published in: Feb 2012
Publisher: Packt
ISBN-13: 9781849517249
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime