O'Reilly Visualizing Data.pdf

(5954 KB) Pobierz
Visualizing Data
Ben Fry
Beijing
Cambridge
Farnham
Köln
Paris
Sebastopol
Taipei
Tokyo
Visualizing Data
by Ben Fry
Copyright © 2008 Ben Fry. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (safari.oreilly.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or
corporate@oreilly.com.
Editor:
Andy Oram
Production Editor:
Loranah Dimant
Copyeditor:
Genevieve d’Entremont
Proofreader:
Loranah Dimant
Printing History:
December 2007:
First Edition.
Indexer:
Ellen Troutman Zaig
Cover Designer:
Karen Montgomery
Interior Designer:
David Futato
Illustrator:
Jessamyn Read
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc.
Visualizing Data,
the image of an owl, and related trade dress are trademarks of
O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information
contained herein.
This book uses RepKover
a durable and flexible lay-flat binding.
,
ISBN-10: 0-596-51455-7
ISBN-13: 978-0-596-51455-6
[C]
Table of Contents
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
vii
1. The Seven Stages of Visualizing Data
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Why Data Display Requires Planning
An Example
Iteration and Combination
Principles
Onward
2
6
14
15
18
2. Getting Started with Processing
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19
Sketching with Processing
Exporting and Distributing Your Work
Examples and Reference
Functions
Sketching and Scripting
Ready?
20
23
24
27
28
30
3. Mapping
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31
Drawing a Map
Locations on a Map
Data on a Map
Using Your Own Data
Next Steps
31
32
34
51
53
iii
4. Time Series
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
54
Milk, Tea, and Coffee (Acquire and Parse)
Cleaning the Table (Filter and Mine)
A Simple Plot (Represent and Refine)
Labeling the Current Data Set (Refine and Interact)
Drawing Axis Labels (Refine)
Choosing a Proper Representation (Represent and Refine)
Using Rollovers to Highlight Points (Interact)
Ways to Connect Points (Refine)
Text Labels As Tabbed Panes (Interact)
Interpolation Between Data Sets (Interact)
End of the Series
55
55
57
59
62
73
76
77
83
87
92
5. Connections and Correlations
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
94
Changing Data Sources
Problem Statement
Preprocessing
Using the Preprocessed Data (Acquire, Parse, Filter, Mine)
Displaying the Results (Represent)
Returning to the Question (Refine)
Sophisticated Sorting: Using Salary As a Tiebreaker (Mine)
Moving to Multiple Days (Interact)
Smoothing Out the Interaction (Refine)
Deployment Considerations (Acquire, Parse, Filter)
94
95
96
111
118
121
126
127
132
133
6. Scatterplot Maps
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
145
Preprocessing
Loading the Data (Acquire and Parse)
Drawing a Scatterplot of Zip Codes (Mine and Represent)
Highlighting Points While Typing (Refine and Interact)
Show the Currently Selected Point (Refine)
Progressively Dimming and Brightening Points (Refine)
Zooming In (Interact)
Changing How Points Are Drawn When Zooming (Refine)
Deployment Issues (Acquire and Refine)
Next Steps
145
155
157
158
162
165
167
177
178
180
iv
| Table of Contents
7. Trees, Hierarchies, and Recursion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
182
Using Recursion to Build a Directory Tree
Using a Queue to Load Asynchronously (Interact)
An Introduction to Treemaps
Which Files Are Using the Most Space?
Viewing Folder Contents (Interact)
Improving the Treemap Display (Refine)
Flying Through Files (Interact)
Next Steps
182
186
189
194
199
201
208
219
8. Networks and Graphs
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
220
Simple Graph Demo
A More Complicated Graph
Approaching Network Problems
Advanced Graph Example
Mining Additional Information
220
229
240
242
262
9. Acquiring Data
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
264
Where to Find Data
Tools for Acquiring Data from the Internet
Locating Files for Use with Processing
Loading Text Data
Dealing with Files and Folders
Listing Files in a Folder
Asynchronous Image Downloads
Using openStream( ) As a Bridge to Java
Dealing with Byte Arrays
Advanced Web Techniques
Using a Database
Dealing with a Large Number of Files
265
266
268
270
276
277
281
284
284
284
288
295
10. Parsing Data
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
296
Levels of Effort
Tools for Gathering Clues
Text Is Best
Text Markup Languages
296
298
299
303
Table of Contents |
v
Zgłoś jeśli naruszono regulamin