100% found this document useful (3 votes)
18 views

Get Pro Data Visualization Using R and JavaScript: Analyze and Visualize Key Data on the Web 2nd Edition Tom Barker PDF ebook with Full Chapters Now

Key

Uploaded by

naieboudhof
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
18 views

Get Pro Data Visualization Using R and JavaScript: Analyze and Visualize Key Data on the Web 2nd Edition Tom Barker PDF ebook with Full Chapters Now

Key

Uploaded by

naieboudhof
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Download Full Version ebook - Visit ebookmeta.

com

Pro Data Visualization Using R and JavaScript:


Analyze and Visualize Key Data on the Web 2nd
Edition Tom Barker

https://ebookmeta.com/product/pro-data-visualization-using-
r-and-javascript-analyze-and-visualize-key-data-on-the-
web-2nd-edition-tom-barker/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmeta.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

Data Visualization with Python and JavaScript 2nd Edition


Kyran Dale

https://ebookmeta.com/product/data-visualization-with-python-and-
javascript-2nd-edition-kyran-dale/

ebookmeta.com

Data Visualization with Python and JavaScript, 2nd Edition


Kyran Dale

https://ebookmeta.com/product/data-visualization-with-python-and-
javascript-2nd-edition-kyran-dale-2/

ebookmeta.com

A Primer in Biological Data Analysis and Visualization


Using R 2nd Edition Gregg Hartvigsen

https://ebookmeta.com/product/a-primer-in-biological-data-analysis-
and-visualization-using-r-2nd-edition-gregg-hartvigsen/

ebookmeta.com

Accounting for Goodwill and Other Intangible Assets 1st


Edition Mark L. Zyla

https://ebookmeta.com/product/accounting-for-goodwill-and-other-
intangible-assets-1st-edition-mark-l-zyla/

ebookmeta.com
Logan 1st Edition Samantha Whiskey

https://ebookmeta.com/product/logan-1st-edition-samantha-whiskey/

ebookmeta.com

Organizational Behaviour: Improving Performance and


Commitment in the Workplace, 5e, Canadian Edition Jason A.
Colquitt
https://ebookmeta.com/product/organizational-behaviour-improving-
performance-and-commitment-in-the-workplace-5e-canadian-edition-jason-
a-colquitt/
ebookmeta.com

Timeout Vegas Aces The Quarterback Book 3 1st Edition


Lisa Suzanne

https://ebookmeta.com/product/timeout-vegas-aces-the-quarterback-
book-3-1st-edition-lisa-suzanne/

ebookmeta.com

Lebanese in Motion Gender and the Making of a Translocal


Village Anja Peleikis

https://ebookmeta.com/product/lebanese-in-motion-gender-and-the-
making-of-a-translocal-village-anja-peleikis/

ebookmeta.com

Downfall and Other Stories 1st Edition Hayashi Fumiko

https://ebookmeta.com/product/downfall-and-other-stories-1st-edition-
hayashi-fumiko/

ebookmeta.com
Ethereum Tools Skills 1st Edition Bruno Skvorc Ahmed
Bouchefra Mislav Javor Tonino Jankov

https://ebookmeta.com/product/ethereum-tools-skills-1st-edition-bruno-
skvorc-ahmed-bouchefra-mislav-javor-tonino-jankov/

ebookmeta.com
Pro Data
Visualization Using
R and JavaScript
Analyze and Visualize Key Data
on the Web

Second Edition

Tom Barker
Jon Westfall
Pro Data Visualization
Using R and JavaScript
Analyze and Visualize Key Data
on the Web
Second Edition

Tom Barker
Jon Westfall
Pro Data Visualization Using R and JavaScript: Analyze and Visualize Key Data
on the Web
Tom Barker Jon Westfall
Pipersville, PA, USA Cleveland, MS, USA

ISBN-13 (pbk): 978-1-4842-7201-5 ISBN-13 (electronic): 978-1-4842-7202-2


https://doi.org/10.1007/978-1-4842-7202-2

Copyright © 2022 by Tom Barker, Jon Westfall


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image by Zanwei Guo on Unsplash (www.unsplash.com)
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004, U.S.A.
Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.
com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media
Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book's product page, located at www.apress.com/9781484272015. For more
detailed information, please visit http://www.apress.com/source-­code.
Printed on acid-free paper
For my grandmother, Ann Biango, who passed away during the
creation of this book. I was very lucky to have her in my life
for as long as I did.
—Tom Barker
Table of Contents
About the Authors���������������������������������������������������������������������������������������������������� xi

About the Technical Reviewer������������������������������������������������������������������������������� xiii


Acknowledgments���������������������������������������������������������������������������������������������������xv

Chapter 1: Background��������������������������������������������������������������������������������������������� 1
What Is Data Visualization?����������������������������������������������������������������������������������������������������������� 3
Time Series Charts������������������������������������������������������������������������������������������������������������������ 4
Bar Charts�������������������������������������������������������������������������������������������������������������������������������� 4
Histograms������������������������������������������������������������������������������������������������������������������������������ 5
Data Maps������������������������������������������������������������������������������������������������������������������������������� 6
Scatter Plots���������������������������������������������������������������������������������������������������������������������������� 7
History������������������������������������������������������������������������������������������������������������������������������������� 8
Modern Landscape���������������������������������������������������������������������������������������������������������������� 12
Why Data Visualization?�������������������������������������������������������������������������������������������������������������� 14
Tools�������������������������������������������������������������������������������������������������������������������������������������������� 15
Languages, Environments, and Libraries������������������������������������������������������������������������������� 15
Analysis Tools������������������������������������������������������������������������������������������������������������������������ 17
Process Overview����������������������������������������������������������������������������������������������������������������������� 20
Identify a Problem����������������������������������������������������������������������������������������������������������������� 20
Gather Data���������������������������������������������������������������������������������������������������������������������������� 20
Analyze Data�������������������������������������������������������������������������������������������������������������������������� 24
Visualize Data������������������������������������������������������������������������������������������������������������������������ 30
Ethics of Data Visualization��������������������������������������������������������������������������������������������������������� 31
Cite Sources�������������������������������������������������������������������������������������������������������������������������� 32
Be Aware of Visual Cues�������������������������������������������������������������������������������������������������������� 32
Summary������������������������������������������������������������������������������������������������������������������������������������ 32

v
Table of Contents

Chapter 2: R Language Primer������������������������������������������������������������������������������� 33


Getting to Know the R Console��������������������������������������������������������������������������������������������������� 33
The Command Line���������������������������������������������������������������������������������������������������������������� 37
Command History������������������������������������������������������������������������������������������������������������������ 38
Accessing Documentation����������������������������������������������������������������������������������������������������� 39
Packages������������������������������������������������������������������������������������������������������������������������������� 40
Importing Data���������������������������������������������������������������������������������������������������������������������������� 43
Using Headers����������������������������������������������������������������������������������������������������������������������� 44
Specifying a String Delimiter������������������������������������������������������������������������������������������������� 45
Specifying Row Identifiers����������������������������������������������������������������������������������������������������� 45
Using Custom Column Names����������������������������������������������������������������������������������������������� 46
Data Structures and Data Types�������������������������������������������������������������������������������������������������� 47
Data Frames�������������������������������������������������������������������������������������������������������������������������� 49
Matrices��������������������������������������������������������������������������������������������������������������������������������� 51
Adding Lists��������������������������������������������������������������������������������������������������������������������������� 54
Looping Through Lists����������������������������������������������������������������������������������������������������������� 55
Applying Functions to Lists��������������������������������������������������������������������������������������������������� 56
Functions������������������������������������������������������������������������������������������������������������������������������� 59
Summary������������������������������������������������������������������������������������������������������������������������������������ 61

Chapter 3: A Deeper Dive into R����������������������������������������������������������������������������� 63


Object-Oriented Programming in R��������������������������������������������������������������������������������������������� 63
S3 Classes����������������������������������������������������������������������������������������������������������������������������� 64
S4 Classes����������������������������������������������������������������������������������������������������������������������������� 68
Statistical Analysis with Descriptive Metrics in R����������������������������������������������������������������������� 70
Median and Mean������������������������������������������������������������������������������������������������������������������ 74
Quartiles�������������������������������������������������������������������������������������������������������������������������������� 74
Standard Deviation���������������������������������������������������������������������������������������������������������������� 75
RStudio IDE��������������������������������������������������������������������������������������������������������������������������������� 76
R Markdown�������������������������������������������������������������������������������������������������������������������������� 78
RPubs������������������������������������������������������������������������������������������������������������������������������������ 83
Summary������������������������������������������������������������������������������������������������������������������������������������ 85

vi
Table of Contents

Chapter 4: Data Visualization with D3�������������������������������������������������������������������� 87


Preliminary Concepts������������������������������������������������������������������������������������������������������������������ 87
HTML������������������������������������������������������������������������������������������������������������������������������������� 88
CSS���������������������������������������������������������������������������������������������������������������������������������������� 90
SVG���������������������������������������������������������������������������������������������������������������������������������������� 91
JavaScript������������������������������������������������������������������������������������������������������������������������������ 94
History of D3������������������������������������������������������������������������������������������������������������������������������� 95
Using D3�������������������������������������������������������������������������������������������������������������������������������������� 96
Setting Up a Project��������������������������������������������������������������������������������������������������������������� 97
Using D3�������������������������������������������������������������������������������������������������������������������������������� 97
Binding Data�������������������������������������������������������������������������������������������������������������������������� 99
Creating a Bar Chart������������������������������������������������������������������������������������������������������������������ 103
Loading External Data��������������������������������������������������������������������������������������������������������������� 111
Summary���������������������������������������������������������������������������������������������������������������������������������� 114

Chapter 5: Visualizing Spatial Data from Access Logs����������������������������������������� 117


What Are Data Maps?���������������������������������������������������������������������������������������������������������������� 117
Access Logs������������������������������������������������������������������������������������������������������������������������������ 121
Parsing the Access Log������������������������������������������������������������������������������������������������������������� 123
Read in the Access Log������������������������������������������������������������������������������������������������������� 124
Parse the Log File���������������������������������������������������������������������������������������������������������������� 125
Geolocation by IP����������������������������������������������������������������������������������������������������������������� 129
Output the Fields����������������������������������������������������������������������������������������������������������������� 132
Adding Control Logic����������������������������������������������������������������������������������������������������������� 134
Creating a Data Map in R����������������������������������������������������������������������������������������������������� 136
Distributing the Visualization����������������������������������������������������������������������������������������������� 146
Summary���������������������������������������������������������������������������������������������������������������������������������� 151

Chapter 6: Visualizing Data over Time������������������������������������������������������������������ 153


Gathering Data�������������������������������������������������������������������������������������������������������������������������� 154
Data Analysis with R����������������������������������������������������������������������������������������������������������������� 155
Calculating the Bug Count��������������������������������������������������������������������������������������������������� 157
Examining the Severity of the Bugs������������������������������������������������������������������������������������ 163
vii
Table of Contents

Adding Interactivity with D3������������������������������������������������������������������������������������������������������ 166


Reading in the Data������������������������������������������������������������������������������������������������������������� 167
Drawing on the Page����������������������������������������������������������������������������������������������������������� 169
Adding Interactivity�������������������������������������������������������������������������������������������������������������� 175
Summary���������������������������������������������������������������������������������������������������������������������������������� 183

Chapter 7: Bar Charts������������������������������������������������������������������������������������������� 185


Standard Bar Chart������������������������������������������������������������������������������������������������������������������� 186
Stacked Bar Chart��������������������������������������������������������������������������������������������������������������������� 188
Grouped Bar Chart�������������������������������������������������������������������������������������������������������������������� 191
Visualizing and Analyzing Production Incidents������������������������������������������������������������������������ 192
Plotting Data on a Bar Chart with R������������������������������������������������������������������������������������������ 197
Ordering Results������������������������������������������������������������������������������������������������������������������ 200
Creating a Stacked Bar Chart���������������������������������������������������������������������������������������������� 202
Bar Charts in D3������������������������������������������������������������������������������������������������������������������������ 203
Creating a Vertical Bar Chart����������������������������������������������������������������������������������������������� 204
Creating a Stacked Bar Chart���������������������������������������������������������������������������������������������� 208
Creating an Overlaid Visualization��������������������������������������������������������������������������������������� 212
Summary���������������������������������������������������������������������������������������������������������������������������������� 217

Chapter 8: Correlation Analysis with Scatter Plots���������������������������������������������� 219


Finding Relationships in Data��������������������������������������������������������������������������������������������������� 220
Introductory Concepts of Agile Development���������������������������������������������������������������������������� 224
Correlation Analysis������������������������������������������������������������������������������������������������������������������ 225
Creating a Scatter Plot�������������������������������������������������������������������������������������������������������� 226
Creating a Bubble Chart������������������������������������������������������������������������������������������������������ 227
Visualizing Bugs������������������������������������������������������������������������������������������������������������������������ 228
Visualizing Production Incidents����������������������������������������������������������������������������������������������� 232
Interactive Scatter Plots in D3�������������������������������������������������������������������������������������������������� 235
Adding the Base HTML and JavaScript������������������������������������������������������������������������������� 235
Loading the Data����������������������������������������������������������������������������������������������������������������� 236
Adding Interactive Functionality������������������������������������������������������������������������������������������ 237

viii
Table of Contents

Adding Form Fields�������������������������������������������������������������������������������������������������������������� 239


Retrieving Form Data����������������������������������������������������������������������������������������������������������� 240
Using the Visualization�������������������������������������������������������������������������������������������������������� 241
Summary���������������������������������������������������������������������������������������������������������������������������������� 245

Chapter 9: Visualizing the Balance of Delivery and Quality with Parallel


Coordinates���������������������������������������������������������������������������������������������������������� 247
What Are Parallel Coordinate Charts?��������������������������������������������������������������������������������������� 247
History of Parallel Coordinate Plots������������������������������������������������������������������������������������������ 251
Finding Balance������������������������������������������������������������������������������������������������������������������������ 254
Creating a Parallel Coordinate Chart����������������������������������������������������������������������������������� 254
Adding in Effort�������������������������������������������������������������������������������������������������������������������� 257
Brushing Parallel Coordinate Charts with D3���������������������������������������������������������������������������� 260
Creating the Base Structure������������������������������������������������������������������������������������������������ 260
Creating a Y-Axis for Each Column�������������������������������������������������������������������������������������� 261
Drawing the Lines���������������������������������������������������������������������������������������������������������������� 262
Fading the Lines������������������������������������������������������������������������������������������������������������������ 263
Creating the Axes���������������������������������������������������������������������������������������������������������������� 264
Summary���������������������������������������������������������������������������������������������������������������������������������� 269

Index��������������������������������������������������������������������������������������������������������������������� 271

ix
About the Authors
Tom Barker is the Senior Manager of Web Development
at Comcast. He has authored Pro JavaScript Performance:
Monitoring and Visualization and co-authored Foundation
Website Creation with HTML5, CSS3, and JavaScript. Tom
has also served as an adjunct professor at Philadelphia
University for the last ten years. He lives outside of
Philadelphia with his wife and two children.

Jon Westfall is an associate professor of psychology at Delta


State University. He has authored Set Up and Manage Your
Virtual Private Server, Practical R 4, Beginning Android Web
Apps Development, Windows Phone 7 Made Simple, and
several works of fiction including One in the Same, Mandate,
and Franklin: The Ghost Who Successfully Evicted Hipsters
from His Home and Other Short Stories. He lives in Cleveland,
Mississippi, with his wife.

xi
About the Technical Reviewer
Matt Wiley leads institutional effectiveness, research,
and assessment at Victoria College, facilitating strategic
and unit planning, data-informed decision making,
and state/regional/federal accountability. As a tenured,
associate professor of mathematics, he won awards in both
mathematics education (California) and student engagement
(Texas). Matt holds degrees in computer science, business,
and pure mathematics from the University of California and
Texas A&M systems.
Outside academia, he has co-­authored three books about the popular R
programming language and was managing partner of a statistical consultancy for
almost a decade. His programming experience is with R, SQL, C++, Ruby, Fortran, and
JavaScript.
A programmer, a published author, a mathematician, and a transformational leader,
Matt has always melded his passion for writing with his joy of logical problem solving
and data science. From the boardroom to the classroom, he enjoys finding dynamic ways
to partner with interdisciplinary and diverse teams to make complex ideas and projects
understandable and solvable. Matt enjoys being found online via Twitter at @matt math
or http://mattwiley.org/.

xiii
Acknowledgments
I want to thank Ben Renow-Clarke for thinking of me for this great project. I want to
thank Matthew Moodie and Christine Rickets and the rest of the team at Apress for their
guidance and direction. I want to thank Matt Canning for helping me see the code with
fresh eyes and for keeping me honest.
I want to thank my team at Comcast: every one of you is amazing and I am made
better by being a part of such an incredible team.
I want to thank my amazing wife Lynn and our beautiful children Lukas and Paloma
for their patience and understanding while I would write every night until late in the
night.
—Tom Barker

I’d like to thank my wife and parents for their love and support. I’d also like to thank the
team at Apress for their hard work to help make this project a reality.
—Jon Westfall

xv
CHAPTER 1

Background
When the first edition of this text was released, there was a new concept emerging in
the field of web development: using data visualizations as communication tools. Today,
Infographics are everywhere on the Net; however, this concept is something that was
already well established in other fields and departments for generations. At the company
where you work, your finance department probably uses data visualizations to represent
fiscal information both internally and externally; just take a look at the quarterly
earnings reports for almost any publicly traded company. They are full of charts to show
revenue by quarter, or year over year earnings, or a plethora of other historic financial
data. All are designed to show lots and lots of data points, potentially pages and pages of
data points, in a single easily digestible graphic.
Compare the bar chart in Google’s quarterly earnings report from back in 2007 (ah,
when Google was a “small” company; see Figure 1-1) to a subset of the data it is based on
in tabular format (see Figure 1-2).

1
© Tom Barker, Jon Westfall 2022
T. Barker and J. Westfall, Pro Data Visualization Using R and JavaScript,
https://doi.org/10.1007/978-1-4842-7202-2_1
Chapter 1 Background

Figure 1-1. Google Q4 2007 quarterly revenue shown in a bar chart

Figure 1-2. Similar earnings data in tabular form

The bar chart is imminently more readable. We can clearly see by the shape of it
that earnings are up and have been steadily going up each quarter. By the color coding,
we can see the sources of the earnings, and with the annotations, we can see both
the precise numbers that those color coding represent and what the year over year
percentages are.

2
Chapter 1 Background

With the tabular data, you have to read labels on the left, line up the data on the
right with those labels, do your own aggregation and comparison, and draw your own
conclusions. There is a lot more upfront work needed to take in the tabular data, and
there exists the very real possibility of your audience either not understanding the data
(thus creating their own incorrect story around the data) or tuning out completely
because of the sheer amount of work needed to take in the information.
It’s not just the finance department that uses visualizations to communicate dense
amounts of data. Maybe your operations department uses charts to communicate
server uptime, or your customer support department uses graphs to show call volume.
Whatever the case, it’s no wonder that engineering and web development groups have
finally gotten on board with this.
As part of any department, group, or industry, we have a huge amount of relevant
data that is important for us to first be aware of so that we can refine and improve what
we do, but also to communicate out to our stakeholders, to demonstrate our successes or
validate resource needs, or to plan tactical roadmaps for the coming year.
Before we can do this, we need to understand what we are doing. We need to
understand what data visualizations are, a general idea of their history, when to use
them, and how to use them both technically and ethically.

What Is Data Visualization?


OK, so what exactly is data visualization? Data visualization is the art and practice of
gathering, analyzing, and graphically representing empirical information. They are
sometimes called information graphics (“Infographics”), or even just charts and graphs.
Whatever you call it, the goal of visualizing data is to tell the story in the data. Telling the
story is predicated on understanding the data at a very deep level and gathering insight
from comparisons of data points in the numbers.
There exists syntax for crafting data visualizations, patterns in the form of charts that
have an immediately known context. We devote a chapter to each of the significant chart
types later in the book.

3
Chapter 1 Background

Time Series Charts


Time series charts show changes over time. See Figure 1-3 for a time series chart that
shows the weighted popularity of the keyword “Data Visualization” from Google Trends
(www.google.com/trends/).

Figure 1-3. Time series of weighted trend for the keyword “Data Visualization”
from Google Trends

Note that the vertical y-axis shows a sequence of numbers that increment by 20 up to
100. These numbers represent the weighted search volume, where 100 is the peak search
volume for our term. On the horizontal x-axis, we see years going from 2007 to 2012. The
line in the chart represents both axes, the given search volume for each date.
From just this small sample size, we can see that the term has more than tripled
in popularity, from a low of 29 in the beginning of 2007 up to the ceiling of 100 by the
end of 2012.

B
 ar Charts
Bar charts show comparisons of data points. See Figure 1-4 for a bar chart that
demonstrates the search volume by country for the keyword “Data Visualization,” the
data for which is also sourced from Google Trends.

4
Chapter 1 Background

Figure 1-4. Google Trends breakdown of search volume by region for keyword
“Data Visualization”

We can see the names of the countries on the y-axis and the normalized search
volume, from 0 to 100, on the x-axis. Notice, though, that no time measure is given. Does
this chart represent data for a day, a month, or a year?
Also note that we have no context for what the unit of measure is. I highlight
these points not to answer them but to demonstrate the limitations and pitfalls of this
particular chart type. We must always be aware that our audience does not bring the
same experience and context that we bring, so we must strive to make the stories in our
visualizations as self-evident as possible.

Histograms
Histograms are a type of bar chart that displays continuous data on both axes. It is
used to show the distribution of data or how often groups of information appear in
the data. See Figure 1-5 for a histogram that shows how many articles the New York
Times published each year, from 1980 to 2012, that related in some way to the subject of
data visualization. We can see from the chart that the subject has been ramping up in
frequency since 2009.

5
Chapter 1 Background

Figure 1-5. Histogram showing distribution of NY Times articles about data


visualization

Data Maps
Data maps are used to show the distribution of information over a spatial region.
Figure 1-6 shows a data map used to demonstrate the interest in the search term “Data
Visualization” broken out by US states.

6
Chapter 1 Background

Figure 1-6. Data map of US states by interest in “Data Visualization” (data from
Google Trends)

In this example, the states with the darker shades indicate a greater interest in
the search term. (This data also is derived from Google Trends, for which interest is
demonstrated by how frequently the term “Data Visualization” is searched for on
Google.) It’s also worth noting that while darker shades tend to be used to indicate
greater impact, without a legend, we wouldn’t know this for sure.

S
 catter Plots
Like bar charts, scatter plots are used to compare data, but specifically to suggest
correlations in the data, or where the data may be dependent or related in some way.
See Figure 1-7, in which we use data from Google Correlate (www.google.com/trends/
correlate), to look for a relationship between search volume for the keyword “What is
Data Visualization” and the keyword “How to Create Data Visualization.”

7
Chapter 1 Background

Figure 1-7. Scatter plot examining the correlation between search volume for
terms related to “Data Visualization,” “How to Create,” and “What is”

This chart suggests a positive correlation in the data, meaning that as one term
rises in popularity, the other also rises. So what this chart suggests is that as more
people find out about data visualization, more people want to learn how to create data
visualizations.
The important thing to remember about correlation is that it does not suggest a
direct cause—correlation is not causation. Just because two numbers move in the same
direction, does not mean one is causing the other to change. There could always be a
third variable, or coincidence, causing the correlation.

History
If we’re talking about the history of data visualization, the modern conception of data
visualization largely started with William Playfair. William Playfair was, among other
things, an engineer, an accountant, a banker, and an all-around Renaissance man who

8
Chapter 1 Background

single-handedly created the time series chart, the bar chart, and the bubble chart.
Playfair’s charts were published in the late eighteenth century into the early nineteenth
century. He was very aware that his innovations were the first of their kind, at least in
the realm of communicating statistical information, and he spent a good amount of
space in his books describing how to make the mental leap to seeing bars and lines as
representing physical things like money.
Playfair is best known for two of his books: the Commercial and Political Atlas and
the Statistical Breviary. The Commercial and Political Atlas was published in 1786 and
focused on different aspects of economic data from national debt to trade figures and
even military spending. It also featured the first printed time series graph and bar chart.
His Statistical Breviary focused on statistical information around the resources of the
major European countries of the time and introduced the bubble chart.
Playfair had several goals with his charts, among them perhaps stirring controversy,
commenting on the diminishing spending power of the working class, and even
demonstrating the balance of favor in the import and export figures of the British
Empire, but ultimately his most wide-reaching goal was to communicate complex
statistical information in an easily digested, universally understood format.

Note Both books are back in print relatively recently, thanks to Howard Wainer,
Ian Spence, and Cambridge University Press.

Playfair had several contemporaries, including Dr. John Snow, who made my
personal favorite chart: the cholera map. The cholera map is everything an informational
graphic should be: it was simple to read, it was informative, and, most importantly, it
solved a real problem.
The cholera map is a data map that outlined the location of all the diagnosed cases of
cholera in the outbreak of London 1854 (see Figure 1-8). The shaded areas are recorded
deaths from cholera, and the shaded circles on the map are water pumps. From careful
inspection, the recorded deaths seemed to radiate out from the water pump on Broad
Street.

9
Chapter 1 Background

Figure 1-8. John Snow’s cholera map

Dr. Snow had the Broad Street water pump closed, and the outbreak ended.
Beautiful, concise, and logical.
Another historically significant information graphic is the Diagram of the Causes of
Mortality in the Army in the East, by Florence Nightingale and William Farr. This chart is
shown in Figure 1-9.

10
Chapter 1 Background

Figure 1-9. Florence Nightingale and William Farr’s Diagram of the Causes of
Mortality in the Army in the East

Nightingale and Farr created this chart in 1856 to demonstrate the relative number of
preventable deaths and, at a higher level, to improve the sanitary conditions of military
installations. Note that the Nightingale and Farr visualization is a stylized pie chart. Pie
charts are generally a circle representing the entirety of a given data set with slices of the
circle representing percentages of a whole. The usefulness of pie charts is sometimes
debated because it can be argued that it is harder to discern the difference in value
between angles than it is to determine the length of a bar or the placement of a line
against Cartesian coordinates. Nightingale seemingly avoids this pitfall by having not
just the angle of the wedge hold value but by also altering the relative size of the slices so
they eschew the confines of the containing circle and represent relative value. This likely
wins over some of the detractors of pie charts; however, in some circles of science and
academia, there is no such thing as a good pie chart!
All the above examples had specific goals or problems that they were trying to solve.

11
Chapter 1 Background

Note A rich comprehensive history is beyond the scope of this book, but if you
are interested in a thoughtful, incredibly researched analysis, be sure to read
Edward Tufte’s The Visual Display of Quantitative Information.

M
 odern Landscape
Data visualization is in the midst of a modern revitalization due in large part to the
proliferation of cheap storage space to store logs and free and open source tools to
analyze and chart the information in these logs.
From a consumption and appreciation perspective, there are websites that are
dedicated to studying and talking about information graphics. There are generalized
sites such as FlowingData that both aggregate and discuss data visualizations from
around the Web, from astrophysics timelines to mock visualizations used on the floor of
Congress.
The mission statement from the FlowingData About page (http://flowingdata.
com/about/) is appropriately the following: “FlowingData explores how designers,
statisticians, and computer scientists use data to understand ourselves better—mainly
through data visualization.”
There are more specialized sites such as quantifiedself.com that are focused on
gathering and visualizing information about oneself. There are even web comics about
data visualization, the quintessential one being xkcd.com, run by Randall Munroe. One
of the most famous and topical visualizations that Randall has created thus far is the
Radiation Dose Chart. We can see the Radiation Dose Chart in Figure 1-10 (it is available
in high resolution here: http://xkcd.com/radiation/).

12
Chapter 1 Background

Figure 1-10. Radiation Dose Chart, by Randall Munroe. Note that the range
in scale being represented in this visualization as a single block in one chart is
exploded to show an entirely new microcosm of context and information. This
pattern is repeated over and over again to show an incredible depth of information

13
Chapter 1 Background

This chart was created in response to the Fukushima Daiichi nuclear disaster of
2011 and sought to clear up misinformation and misunderstanding of comparisons
being made around the disaster. It did this by demonstrating the differences in scale
for the amount of radiation from sources such as other people or a banana up to what a
fatal dose of radiation ultimately would be—how all that compared to spending just ten
minutes near the Chernobyl meltdown.
Over the last quarter of a century, Edward Tufte, author and professor emeritus at
Yale University, has been working to raise the bar of information graphics. He published
groundbreaking books detailing the history of data visualization, tracing its roots even
further back than Playfair to the beginnings of cartography. Among his principles is
the idea to maximize the amount of information included in each graphic—both by
increasing the amount of variables or data points in a chart and by eliminating the use
of what he has coined chartjunk. Chartjunk, according to Tufte, is anything included in a
graph that is not information, including ornamentation or thick, gaudy arrows.
Tufte also invented the sparkline, a time series chart with all axes removed and only
the trend line remaining to show historic variations of a data point without concern for
exact context. Sparklines are intended to be small enough to place in line with a body
of text, similar in size to the surrounding characters, and to show the recent or historic
trend of whatever the context of the text is.

Why Data Visualization?


In William Playfair’s introduction to the Commercial and Political Atlas, he rationalizes
that just as algebra is the abbreviated shorthand for arithmetic, so are charts a way
to “abbreviate and facilitate the modes of conveying information from one person to
another.” Almost 300 years later, this principle remains the same.
Data visualizations are a universal way to present complex and varied amounts of
information, as we saw in our opening example with the quarterly earnings report. They
are also powerful ways to tell a story with data.
Imagine you have your Apache logs in front of you, with thousands of lines all
resembling the following:

127.0.0.1 - - [10/Dec/2012:10:39:11 +0300] "GET / HTTP/1.1" 200 468 "-"


"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20061201
Firefox/2.0.0.3 (Ubuntu-feisty)"

14
Chapter 1 Background

127.0.0.1 - - [10/Dec/2012:10:39:11 +0300] "GET /favicon.ico HTTP/1.1" 200


766 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20061201
Firefox/2.0.0.3 (Ubuntu-feisty)"

Among other things, we see IP address, date, requested resource, and client user
agent. Now imagine this repeated thousands of times—so many times that your eyes
kind of glaze over because each line so closely resembles the ones around it that it’s hard
to discern where each line ends, let alone what cumulative trends exist within.
By using some analysis and visualization tools such as R, or even a commercial
product such as Splunk, we can artfully pull out all kinds of meaningful and interesting
stories out of this log, from how often certain HTTP errors occur and for which resources
to what our most widely used URLs are, to what the geographic distribution of our user
base is.
This is just our Apache access log. Imagine casting a wider net, pulling in release
information, bugs, and production incidents. What insights we could gather about what
we do: from how our velocity impacts our defect density to how our bugs are distributed
across our feature sets. And what better way to communicate those findings and tell
those stories than through a universally digestible medium, like data visualizations?
The point of this book is to explore how we as developers can leverage this practice
and medium as part of continual improvement—both to identify and quantify our
successes and opportunities for improvements and more effectively communicate our
learning and our progress.

T ools
There are a number of excellent tools, environments, and libraries that we can use both
to analyze and visualize our data. The next two sections describe them.

Languages, Environments, and Libraries


The tools that are most relevant to web developers are Splunk, R, and the D3 (Data-­
Driven Documents) JavaScript library. See Figure 1-11 for a comparison of interest over
time for them (from Google Trends).

15
Chapter 1 Background

Figure 1-11. Google Trends analysis of interest over time in Splunk, R, and D3

From the figure, we can see that R has had a steady consistent amount of interest
since 200; Splunk had an introduction to the chart around 2005, had a spike of interest
around 2006, and had steady growth since then, which only started tapering off in
2019. As for D3, we see it just start to peak around 2011 when it was introduced and its
predecessor Protovis was sunsetted. R and D3 have remained relatively stable in interest
in the years since 2013.
Let’s start with the tool of choice for many developers, scientists, and statisticians:
the R language. We have a deep dive into the R environment and language in the next
chapter, but for now, it’s enough to know that it is an open source environment and
language used for statistical analysis and graphical display. It is powerful, fun to use,
and, best of all, it is free.
Splunk has seen a tremendous steady growth in interest over the last few years—and
for good reason. It is easy to use once it’s set up, scales wonderfully, supports multiple
concurrent users, and puts data reporting at the fingertips of everyone. You simply set it
up to consume your log files; then you can go into the Splunk dashboard and run reports
on key values within those logs. Splunk creates visualizations as part of its reporting
capabilities, as well as alerting. While Splunk is a commercial product, it also offers a free
trial version, available here: www.splunk.com/download.
D3 is a JavaScript library that allows us to craft interactive visualizations. It is the
official follow-up to Protovis. Protovis was a JavaScript library created in 2009 by Stanford
University’s Stanford Visualization Group. Protovis was sunsetted in 2011, and the
creators unveiled D3. We explore the D3 library at length in Chapter 4.

16
Chapter 1 Background

A
 nalysis Tools
Aside from the previously mentioned languages and environments, there are a number
of analysis tools available online.
A great hosted tool for analysis and research is Google Trends. Google Trends
allows you to compare trends on search terms. It provides all kinds of great statistical
information around those trends, including comparing their relative search volume (see
Figure 1-12), the geographic area those trends are coming from (see Figure 1-13), and
related keywords.

Figure 1-12. Google Trends for the terms “data scientist” and “computer scientist”
over time; note the interest in the term “data scientist” growing rapidly from 2011
on to match the interest in the term “computer scientist”

17
Chapter 1 Background

Figure 1-13. Google Trends data map showing geographic location where interest
in the keywords is originating

Another great tool for analysis is Wolfram|Alpha (http://wolframalpha.com). See


Figure 1-14 for a screenshot of the Wolfram|Alpha home page.

Figure 1-14. Home page for Wolfram|Alpha

18
Discovering Diverse Content Through
Random Scribd Documents
pirunkamaria. Tuoss' on ovi! — Kukaan sit' ei estä avaamasta!
Mene katsomaan, niin näet itse!

PALV. I

Totisesti, se mun täytyy tehdä!

(Lähestyy pirunkamarin ovea.)

MUSTALAISTYTTÖ (keskeyttää laulunsa Palv. I:n koskettaessa


pirunkamarin ovea. Puhuu valittavalla, kovalla äänellä.)

Kolme kertaa perätysten tuli


huonot kortit. Mitähän tuo tiennee…

PALV. I (kirkaisee.)

Hui kun pelästyinkin, melkein pyörryin!


Mikä tuonkin joikumaan toi tänne!

PALV. II (menee mustalaistytön luo.)

Kuules, mitä kortit sitten sanoo?

MUST.-T.

Ristiverinen tuo miesi käypi veden yli, mutta mitä aikoo,


missä, kenen kanssa? Sit' en näe — Tulossa on jotain
kaameata!

PALV. II

Ole höpsimättä, tyttöparka!


(Nauraa ja ottaa kortit sekä istuu vastapäätä mustalaista.)

Jotain ihanaa tuo ens' yö meille!


Anna, kun ma itse povaan teille!

KAARINA (tulee perältä.)

PALVELIJAT I & II (asettuvat kunnioittaviin asentoihin.)

MUST.-T. (samoin.)

KAARINA (palvelijoille:)

Huone näyttää siistitylle. Menkää

PALVELIJAT I & II (menevät.)

KAARINA (mustalaistytölle:)

Tule toisten laulajien kanssa.

MUST.-T. (menee.)

KAARINA (soittaa.)

PALV. (tulee.)

KAARINA

Kutsu mestarkokki puheilleni.

PALV. (tuo mestarkokin. Menee.)

KAARINA
Peura, joka tänään metsästettiin, tuodaan ryytein kanssa
paistettuna puol'yön aikaan vierahille pöytään.

MEST.-KOKKI.

Puol'yön aikaan! Eikö ole hiukan — sopimaton paistin


syönnin hetki?

KAARINA

Joka hetki, jonka siihen määrään, sopiva on sulle, vanha


paisti!

(Nauraa.)

MEST.-KOKKI

Pyydän anteeks'! Armollisen rouvan tahdon mukaan tulee


tapahtumaan!

(Menee.)

KAARINA (yksin.)

Kuink' on elo ihana ja kaunis! Kaikki muuttanut on väriänsä:


Talot valkeet nuo ja tiilikatot, kirkot torneineen ja linnoitukset,
saaret, salmet, männiköt, niin myöskin vehreet tammet nuo.
— Maa on niin kaunis! — Ihmisetkin muuttuneet on kaikki,
katselevat minuun hymyellen. Onnetar mua seuraa kaikkialla,
kuljen ruusuin, kukkasien päällä. Jotkin suomukset on
silmistäni pudonnehet eilispäivän jälkeen. Eilen tuskin
nimeltänsä tunsin miestä, joka nyt on mulle kaikki! — Kirsti-
rouva, oi kun oisit tässä! Suudella sun nuuskanaamaas voisin
riemusta — kun autoit meidät yhteen. Voisin antaa yhden
tuhansista hänen antamistaan sulle näytteeks'. — Eilisaamuna
viel' olin köyhä, kurja niinkuin alli aaltoloilla, murheinen kuin
syysyö pitkä, synkkä. — Nyt kuin onnenaatos autuaitten, tai
kuin päivännousu kevätaikaan! — Ihme! Turun ritarit mun
vasta löysivät, kun minut ensin löysi Olaus Hordinch, meren
vapaa kotka. — Jokainen nyt kehuu silmiäni. — Jäljessäni
juoksevat nyt kaikki: vanhat, nuoret, naineet, naimattomat
etsimässä tilaisuutta antaa suuta manttelini liepehelle. —
Runoutta pursuu suusta kaikkein, täynnä rakkautta, lemmen
tuskaa. — Runottomin heist' on Olaus Hordinch, — tulee,
syliin ottaa, muiskun antaa — kysyy: "Kuinka jaksat
pulmuseni?" — Näkisitpä herra Kuokkinainen! Siin' ois sulle
oivaa koulutusta. — Surkein on tuo ritar' Kovasydän sairaan
rakkautensa hommailuissa. — Kokoo taskuhunsa tieltä hiekan,
johon kengälläni jäljen poljin. Vedet silmistä häll' aina virtaa,
milloin hälle hyvän taikka pahan sanan lausun, yhteen
sattuissamme, jolloin änkyttää hän: "Nöö, nöö, — öö", Siihen
vastaan: "Niin, niin, aivan oikein. Kaunis ilma tänään, linnut
laulaa."

(Nauraa:)

Runoutta laadultaan on tuokin,


pelkkää riimiä, ei mitään muuta.
Melkein sanatonta, tunteellista. —
Säälittävä on tuo ritarparka!

Ah voi! Rinnan alle koskee aatos, mieli kurkkuun nousee


huomatessain, että huomenna jo tääll' on tyhjää, että ensi
yönä pois jo lähtee Olaus, sydämeni ilo, turva. — Torstai-
aamun aurinko kun nousee, Ruissalon se typötyhjän kultaa.
— Sitten minä alan paastoajan, kuinka pitkän, — Jumala sen
tietää. Pilkkasin sua, ritar' Kovasydän, mutta saanen
huomeneltain käydä autioissa lehtokäytävissä sinun laillas'
yksin, hyljättynä, etsimässä jälkee saksansaappaan, jolla
Olaus Hordinch hiekkaa polki. Kokoon helmoihini joka jyvän
säilyttääksein kultarasiassa…

OLAUS HORDINCH (tulee varovasti sisään perältä vasemmalta.)

KAARINA (huomaa hänet.)

Joku tulee! — Se on Olaus Hordinch!


Kuinka ihanaa! Hän tulee yksin! —
Tästäpä voi soma juttu nousta!
Hiipisinkö pakoon, — vaiko jäisin?
Jalat käskee pakoon juoksemahan,
sydänparka kapsahtamaan kaulaan! —

OLAUS H.

Sielläpä sa olet, karkulainen!

(Sulkee syliinsä Kaarinan. Suutelevat.)

Kuinka jaksat lintuseni tänään?


"Hyvin!" vastaa silmät, posket, suukko.

(Katselee Kaarinaa:)

Mistä on tuo ryppy otsaan tullut?


KAARINA

Lupaa kysymättä siihen tuli — tuli ammoin jo, ei äsken


tullut. —

OLAUS H.

Sekä rypyn alut silmäkulmiin?

KAARINA

Samaa tietä nekin siihen tuli.

OLAUS H.

Ihme kumma! Niinkuin ensi kertaa vasta tarkastaisin


ihmislasta!

KAARINA

Etkö kellään ennen nähnyt näitä!

OLAUS H.

Ryppyjäkö? Näin — tai enhän nähnyt.


Ja jos näin, en ajatellut mitään.

KAARINA

Mitä nyt siis ajattelet, kulta?

OLAUS H.
Ajattelen? En niin mitään — Mutta sanos mulle, miksi
ihmiseltä ainoastaan kasvot rypistyvät!

KAARINA

Etkö tunne vanhaa sananpartta:


"Kasvot kantavat suruja,
hartiat eväsmuruja." —
Ensin sortuu suuritaakkaisempi.

OLAUS H.

Soisin aina luonas' olevani, suruilta sua armas suojaamassa.


— Soisin, että oisit Voionmaalla! — Aamuin veisin sinut
korkealle kesäaamuamme ihailemaan. Näin me siellä myöskin
seisoisimme. Sinä armas silloin haasteleisit: "Päivä paistaa,
näätkö Olaus sitä? — Nousee merestä ja laskee sinne, —
kulkee yli taivaan jättikuvun, paistaa meille, meille
ainoastaan!" — Sanos, mikä tääll' on kaunehinta?

KAARINA

Miksi sitä kysyt, sano, miksi?

OLAUS H.

Tietääkseni, onko kaunis sama sinun silmissäsi, niinkuin


minun.

KAARINA
Päivän nousun aikaan talviaamu, kullatessaan akkunani alla
pakkashuurtehisen koivun latvaa. — Sitäpä et ole sinä nähnyt!
— Mutta kuules, sinun täytyy heti täältä mennä tuonne
toisten joukkoon. Tulin tänne kohtausta varten miehein, herra
Hennekinin kanssa, tuumiaksein juhlan asioita. Voisi ruma
juttu tästä tulla, jos hän näkis meidät täällä kahden.

(Pelästyen:)

Ah, jo kuulen hänen askelensa!


Mene Luojan tähden edes piiloon!

OLAUS H.

Miksi piiloon, sano, miksi piiloon?


Kuulut mulle, etkä suinkaan tuolle.
Tottunut oon julkihyökkäyksiin. —
Tapa ei oo meikäläisten kesken
kauan mietiskellä, mitä aikoo:
Tuoss' on vieras laiva, kallis lasti:
Hyökkäyssillat alas! Kiinni koukut!
Miehet valtauskirveinensä hyökkää.
Hetken taistelu: Jo kansi selvä,
ruumiit mereen! Laiva, lasti, oma!

KAARINA

Älä sekoita nyt asioita. Vieraan laivan kimppuun asein


käydä yksinkertaisempaa on kuin tämä! — Hillitse nyt itses,
mene piiloon! Muista, että jos teet tyhmyyksiä, minä kärsin
niistä. Sinä menet ehkä ikipäiviksesi täältä. — Minä tänne
jään ja kärsin kaiken. — Minun tähtein tee, kuin minä toivon!
OLAUS H.

Myöhäistä on, hän jo siinä tulee.

(Osoittaa Hennekiniä, jonka on huomannut.)

HENNEKIN (tulee. Olaus H:lle:)

Suokaa anteeks. Turunmaall' on tapa perhejuhliin pyytää


paljon kansaa — Kaikkia ei tunne huono muisti. — Ootko sinä
kuulu Olaus Hordinch, herra Voionmaan ja Valtiasmeren?

OLAUS H.

Taivaan ystävä ma olen sekä kaikkein vihamies. — Lie nimi


tuttu?

HENNEKIN

Jos sa lienet itse Olaus Hordinch, virka mulle: Onko


Voionmaalla tapa jalosukuin ritarien — isänniltään vaimo
viekoitella?

OLAUS H.

Herra Hennekin jos lienet, virka: Onko tapa jaloin ritarien


täällä Turunmaalla jättää rouvat juhlavierahien viekoitella?

HENNEKIN (paljastaa miekkansa.)

Tapa tääll' on antaa miekan laulaa, antaa säilän maistaa


roiston kaulaa!
OLAUS H. (on paljastanut miekkansa.)

Roisto itse lienet! — Siitä syystä säilärautain häpee


paljastustaan, pelkää moisen miehen nahkaa, luita! — Koira
lienet, taikka koiran ruoka! Valmis olen miekkas laulajaisiin!

HENNEKIN

Tuonpa viime sanoiksesi lausuit, haukuit, niin myös kuole


koiran lailla!

(Hyökkää hurjasti. Juhlayleisöä alkaa keräytyä saliin.)

(Olaus lyö Hennekinin kädestä miekan, joka rämisten lentää


lattialle.
Hennekin ottaa jälleen joutuisasti miekan vasempaan käteensä.)

TOHTORI KARPALANUS

Mitä hittoa ma täällä näen!


Herrat mittelevät miekkojansa!

PAAVALI

Miekka ylös, herra Kuokkinainen! —


Ottakaapa kiista uudestansa!

KARPALANUS (nauraa)

Leikki tuo nyt jääköön teiltä siihen, laastarit on kaupungissa


asti. Kuullaan ensin, mik' on asiana, sitten miehiss'
arvostellaan vasta, sanatko vai miekat tässä auttaa. Taistelkaa
senjälkeen tapain mukaan.
(Miekat tuppeen.)

OLAUS H.

Kuinka haluatte! Mull' ei ole syytä keskusteluun hänen


kanssaan. Näitte, miten keskustelu päättyi!

(Nauraa.)

(Juhlavieraat alkavat keräytyä saliin. Kaarina ja muut naiset


istuutuvat paikoilleen. Osa miehistä keräytyy Hennekinin ja Olaus
Hordinchin ympärille. Hälinää.)

RITARI SUOMELA (tulee viimeisenä. Huutaa.)

Miehet hoi, tuo oli huono alku! Onko siellä ehkä korpin
raato, vaiko vanhat korpit raadon luona?

OLAUS (Suomelalle:)

Raato on, ja sieltä korppi lisää!

(Melu taukoaa yht'äkkiä. Kaikki odottavat taistelua Olaus


Hordinchin ja ritari Suomelan välillä, jotka jäävät yksinään
permannolle.)

ERÄS VANHA ROUVA (vierusnaapurilleen määkivällä äänellä:)

Tekeekin taas hyvää istuminen, — promenaadi väsytti jo


mua.

HENNEKIN (ovensuussa seisoville antilaille:)

Viini kantakaatte heti sisään!


(Vieraille:)

Miten sanookaan se sananlasku:


"Sinun sikoja, minun sikoja,
syötetyitä, laihtuneita.
Syötetyt minun sikani,
laihtuneet sinun sikasi."
Istukaa siis pöytään, syökää, juokaa,
ettei tarvis sanoaksein teistä
lähteissämme täältä Ruissalosta:
"Laihtuneet minun sikani!"

(Naurua. Kättentaputuksia. Piiparit puhaltavat hurjan toitotuksen.


Kaikki asettuvat sen ajalla paikoilleen. Tarjoilu alkaa.)

KIRSTI

Ritar' Suomela, oi laula meille, jalon kieles anna kukkuella!

SUOMELA

Laulaisinko? Ja myös taitaisinko? — Kosk' ei täällä


nuoremmat mua pyydä, laulan teidän pyynnöstänne, rouva!

(Ottaa kitaran, jolla säestää.)

Kääpönen, kääpönen käpälällä kukkuu. Neitonen


neitonen illalla itkee. Toivonen, toivonen toisessa
talossa.

(Kirstille imelästi:)
Maammonen, maammonen mansikoilta
maistuvainen heinillä herskuu, nurmella nurskuu,
tinasolkiloissa, sulkkukauhtanoissa, kultarenkahissa,
punasormuksissa.

Tämä laulu oli tarkoitettu rouva Kirstin sulo tyttärelle, neiti


Sinikalle ihanalle.

KIRSTI

Tyttäreni eestä teitä kiitän. — Naisen kainoudelleni ei sovi


siitä kiittää, että laulussanne maammo mainittiin myös
ohimennen.

(Nauraa.)

SUOMELA (Kirstille imelästi:)

Kiittäkää, oi älkää kainostelko!

(Ritari Kovasydämelle:)

Nyt on vuoro teidän laulaa runo rakkaudesta, herra


Kovasydän.

KOVASYDÄN (laulaa katsellen haikeana Kaarinaa:)

Kuu merta hopeoipi, yökehrääjä vain soipi


Ruissalon lehvikoissa, kun yksin unelmoissa käyn
armaan akkunalle ja laulan rakkaimmalle.

Tuon lauluiss' uhrin sulle, mun syömein valitulle. —


Kuin pyhiinvaeltaja, reliikkein kokoaja sun varjossas'
ma valvon ja muistoasi palvon.

HENNEKIN (kuuntelematta laulua loppuun, tohtori


Karpalanukselle:)

Kalaan lähdetä ei ensi yönä, pohjatuuli yltyy, myrskyks


muuttuu, apajat on tyhjät, kalattomat. Eikä myrskyllä oo
hauska olla nuotiolla yötä viettämässä. — Sadekin voi siitä
vielä tulla.

KARPALANUS

Tulossa lie siitä rajuilma. — Kaiken päivää ukonilmaa


hautoi, tuuli pyörinyt on sinne tänne, asettuen viimein
pohjoiseksi.

SUOMELA (laulun jälkeen.)

Tämä malja talon emännälle, rouva Kaarinalle, niinhän,


proosit!

(Huutoja: "Hei, hei!")

KAARINA

Malja neiti Sinikalle, proosit!

(Vielä suurempi melu.)

KIRSTI

Tämä on jo hävytöntä, tämä! Tyttäreni kunnia ei siedä


juoda mointa maljaa salaviittein! Onpa liian julkinen tää
paikka sanoaksein, mitä ajattelen!

(Vihasta punaisena:)

Olkoon nyt jo sanottu sen verran, että kiellän kaikki


viittaukset mokomainkin maljan juontein kautta!

KAARINA

Onpa liian julkinen tää paikka katsoaksein, onko


luonnontukka sulla, vaiko peru vainajilta!

(Hurjaa melua. Huuto: "Rouvat miekkasille!")

Maljani ei mitään tarkoittanut.


Leikin ymmärtänet niinkuin muutkin.

KIRSTI (viskaa peruukkinsa Kaarinaa kohti.)

Saathan tämän, jos sun mieles tekee!


Saat sen sovinnolla, saatpa niinkin!

(Poistuu kiukkuisena taluttaen tytärtään. Naurua ja melua.


Peruukki jää lattialle. Jotkut rouvat lohduttavat loukkaantunutta
Kaarinaa. Herrat kiistelevät ritari Suomelan kanssa. Viinipikarien
uudestaan täyttyessä kaikki rauhoittuvat.)

ERÄS VANHA ROUVA.

Luulin kuulleheni minä tuolla vanhain herrain juttelevan


siitä, ettei ensi yönä nuotanveto maittaisikaan, niinkuin aina
ennen. Oisinkohan liian utelias kysyessäin, mikä tuohon
mahtais olla perimmäinen syy ja este? — Kulkee täällä siitä
kummat huhut.

OLAUS H.

Pohjatuuli, myrsky, kuulettehan, se se kalamiehet jätti maihin.


Ja se sama tuuli meidät viepi, meren virmain ratsuin ajelohon.

ROUVA

Eikö peloita tuo meri teitä?

OLAUS H.

Eihän toki, maalla ehkä joskus. — Maissa meidän


merenkyntäjien koskaan ei oo hyvä kauan olla. Tapa
voijolaisten tuo on vanha: purjehtia, milloin vain on tuulta.
oisin mieluummin — ja mieluisimmin, yön kun mustan halki
myrsky vyöryy.

RITARI MAX (eräs vöiolainen, innostuen edellisestä:)

Yli senkin, milloin päälliköllä laivassansa maalta saatu heila.


Silloin laivat jumalaisin siivin lentävät kuin hurjat myrskyn
henget. Ilotulet syttyy, räiskyy, sammuu. Huuto, laulut kaikuu
yli laivain. Aaltoin mellastuksen takaa viimein punaisena
aamukylvystänsä nousee päivä, vanha Ikitaatto, hymyellen
poikasilleen meille, purppuroiden maan, mi pilven lailla
aalloist' ylenevi: Voionmaamme.

OLAUS (nauraa.)
Runoilijaks Max käy aina päissään!

ROUVA

Toiset taas on runoilustaan päissään! Mutta meidäthän jo


toistamiseen kysymyksestämme harhaan vietiin! Syy siis
lienee jokin erikoinen eikä, niinkuin sanottihin, myrsky, koska
vastaus on kiertelevä — nimittäin tuon kalaretken suhteen.

RITARI SUOMELA

Aamun koitoss' siellä kävi — Piru!

NAISET KUOROSSA

Piru!

SUOMELA

Niin. Sen kanss' ei ole lysti olla; siksi nuottareissut loppui


siihen.

KANIIKKI HORDINCH

Jutussa on perää vain sen verran, herra Hennekin ett' unta


näki jotain Pirusta, tai siihen suuntaan.

NAISET

Kertokaa, se oisi mieliks' meille!

KAN. HORDINCH
Muutahan siin' ei oo kertomista.

NAISET

Ihan varmaan jotain muuta oli, koska miehet miekalliset


pelkää!

ROUVA

Sikäli kuin muistan eivät ennen nuottaretket jääneet —


myrskyn vuoksi.

KAARINA

Hennekin on vaalea par'aikaa; jotain kummallista tässä


onpi.

OLAUS

Ettei turhan vuoksi pelattaisi, toivon, että nuottamiehet


tässä, meille heti kaiken selvittävät.

KAN. HORDINCH

Minä parhaan osan yötä nukuin. — Sitä ennen nautin


rypäleistä. — Heräsin vain jonkinlaiseen meluun jonkun
herättäissä isäntäämme, joka oli saanut kohtauksen — pahan
unen taikka painajaisen. — Niinhän sattua voi jokaiselle!

HENNEKIN

Oli siinä vielä jotain muuta.


NAISET

Senhän arvasimme, kerro, kerro!

KARPALANUS

Ole joutavia kertomatta!

HENNEKIN

Mikä estää mua kertomasta! — Pysyväthän edes


huonehissa! Välttyväthän synnin askelista pelätessään öistä
lehtokujaa kauempana ihmisasunnoista.

SUOMELA

Kerro pois vain illan kunniaksi! — Kaikki opiks' on min


saamme tietää elkeistä tuon vanhan sarvipäisen!

KAARINA

Älä kerro, muutenkin jo meitä peloittaa niin että


vapisemme.

SUOMELA (asettuen Kaarinan viereen:)

Sallikaa mun turvaa tarjotaksein.

KAARINA

Kiitos! — Kuinka usein tätä ennen naiset teiltä saivat turvaa


tuota sarvipäätä sorkkajalkaa vastaan! — Jos nyt tuohon
paikkaan ilmestyisi, eiköhän vain kävis teille niinkuin ennen
Aninkaisten suutarille, joka sitä viskas' lestillänsä.

NAISET

Miten sille sitten kävi, kerro!

KAARINA

Miten kävi! Lesti lensi vatsaan sekä siitä selän kautta ulos.
lentäin läpi sen kuin ilman läpi. Irvistäen oli suutarille
nauranut se kädet vatsallansa lausuellen: "Heitäs toinen
lesti!"

(Nauraa.)

LIHAVA ROUVA (nauraa tukehtuakseen.)

"Heitäs toinen lesti", voi, voi sentään!


"Heitäs toinen lesti", voi, voi sentään!

VANHA NEITI (piipittävällä äänellä.)

Tänään meill' on täysikuu, ma luulen. — Toivon, että


hetkeks' hiljenemme kuullaksemme, pirunkamarissa
kummitus jos soittaa kitaralla. —

(Kaikki vaikenevat ja kuuntelevat suut auki. Usealta jää pikari


puolitiehen, viemättä huulille. Kuuluu hyvin kaukainen kitaran soitto
ja vielä kaukaisempi koiran ulvonta.)

YLIANTILAS (tulee hiljaisuuden vallitessa äänettömin askelin


Hennekinin luo, jolle puhuu.)
Dominikaanien on munkki siellä,
pyytää tänne saarnalupaa sula.

HENNEKIN

Munkki? Mik' on hänet tänne tuonut?

(Vierailleen.)

Annan teille täyden päätösvallan, saako munkki tulla, vaiko


mennä.

KAARINA

Anna saarnaamaan tuon munkin tulla, maksutonhan tuo on


lysti meille!

(Ääniä: "Antaa munkin tulla." "Ei saarnaa!" "Ulos tanssimaan!")

HENNEKIN

Minun luullakseni melkein kaikki tahtoo munkin saarnaa


kuulla, niinkö?

(Ääniä: "Hyvä, hyvä.")

Isäntä on "hyvä", jos hän antaa, mistä vieraat huvitusta


saavat.

(Ääniä: "Oikein, oikein.")

(Yliantilaalle:)

Käske saarnaaja siis sisään heti!


(Yliantilas tuo sisään munkin. Kaikki silmäilevät häntä uteliaina.
Samoin munkki tarkastelee tyhmällä ylpeydellä kuulijakuntaansa.
Yliantilas poistuu. Munkki, vanha laiha dominikaani, vanhassa
kuluneessa kaavussa. Tukka ja eteenpäin törröttävä parta valkoiset.
Parta leikattu tasapäiseksi. Asettuu keskelle, taustalle. Hän esittää
saarnansa laulavalla äänellä, vilkkaiden ruumiinliikkeiden
säestämänä. Etenkin hänen oikea etusormensa liikkuu vilkkaasti ja
näyttää pitemmältä kuin se onkaan. Kantapäät kohoilevat
lakkaamata; näyttää toisinaan kuin hän hyppisi. Polvet notkuvat
saarnan tahdissa. Toisinaan hän kyyristyy hyvin syvään.
Kiihkeimmissä kohdissa ääni muuttuu veisuun tapaiseksi. Alussa
hänen silmänsä kiiluvat avoimina, mutta sitten hän haltioituu ja
saarnaa silmät ummessa. Saarnan aikana kuuluu ulkoa laulua ja
soittoa, sillä osa juhlaväkeä on mennyt heti munkin tultua ulos.)

MUNKKI

Tässäkin Turun kaupungissa, ylpeillen turkiskauluksissa


kulkevat vanhat, kulkevat nuoret, sisältä saastaa ja kuolleiden
luita. — Baabelin porttoja riivatuita! — Sokeat silmänsä kiinni
sulkein, helvetin portteja kohti kulkein menevät tuomarit,
menevät raadit, menevät muorit, menevät vaarit, menevät
piispat, menevät papit, menevät anopit, menevät apit, herrat
hihkuen edellä, narrit nauraen perässä. — Juopuen viinillä,
medellä, kaikki yhdessä kerässä niinkuin ennen Sodomassa,
taikka tuolla Gomorrassa, saman ne halun täältä saivat;
juhlivat, juovat, syövät ja naivat. — Niinkuin ennen Noan
aikaa, varoitusääni nytkin kaikaa: Quia nminor dminicani
siispä kuulkaa haukuntaani, Turun rikkaat ja Turun köyhät,
tavoilta kaikki yhtä löyhät. — Ennen isät kuritti lastaan,
hornanhenkiä tapellen vastaan, nyt on isät ennen muita
saatanan hengeltä riivatuita. Ennen Herran kansan nähtiin
kääntävän silmänsä taivaan tähtiin, tuonne Herran Zebaothin
puoleen, sielunsa jättäen taivaan huoleen, taivaan pyhille
itsensä antain, Jesu-Herralle kaikkensa kantain, kirkolle oikeat
kymmenykset, sekä synnistä kääntymykset, lihan himosta
itsensä kieltäin. — Nainen, luoduista kauhein naaras, tähtes'
on monikin pyhimys vaarass' Kuinka monta on tässäkin
joukoss', jok' ei olisi helvetin loukoss'! Rutto, paiseet, sota ja
pauhu, riita ja meteli, kuoleman kauhu, kaikki seurasi teille
siitä! Mitä sa kylvät, sitä sa niitä! Oi sinä suloinen Suomen
kansa, syntisi saakohon Gomorransa! Oisko kymmenen
vanhurskasta, ketkä ei laanneet uskomasta keralla miesten
pyhien sovitusuhria Kiesuksen! — Katseli tänne tai katseli
sinne, katseli tuonne ja katseli minne, lopun merkit on
huomattavissa maassa, kuussa ja taivahissa. Lopun merkit on
tähtikunnassa, lopun merkit on kivikunnassa, lopun merkit on
kasvikunnassa, lopun merkit on eläinkunnassa, lopun merkit
on ihmiskunnassa, lopun merkit on enkelikunnassa, lopun
merkit on kristikunnassa, lopun merkit on juudakunnassa,
lopun merkit on mahomettikunnassa, lopun merkit on
pakanakunnassa. — Kuorma tää on Moabin! Kuorma tää on
Naphtalin! Kuorma tää on Babylonin! Vitsaus Egyptin
faraonin! Erämaan kuorma tykönä meren, hinta syyttömän
karitsanveren! Herra, paaduta tämä kansa, ettei se kuulis
korvillansa, että sen silmät valotta jäisi, ettei sen sydän
ymmärtäisi, ettei se kääntäis itseänsä, ettei se parantais
elämätänsä!

Herra, oo kuinka kauan!


Siihen asti, kun kaupungin huoneet kaiken väkens' on
hautaan luoneet! Siihen asti, kun kaikki maa elottomuutta
vain kuuluttaa: Ilman väettä linnat on herrain, ilman väettä
töllit narrein, lopussa porttoin huvi-illat, lopussa pappein,
kreivein pillat.

(Hennekin puhuttelee nuottatovereitaan, joiden kanssa poistuu


hiipien perälle ja oikealle. Yksi ja toinen seuraa näiden esimerkkiä.
Useimmat menevät puutarhaan ja hajaantuvat eri suunnille. Munkki
jatkaa keskeymättä saarnaansa huomaamatta ulosmenijöitä.)

Silloin Herramme Zebaoth laittaa pidot, mi kaikille pyhille


maittaa, pidot rasvasta, ytimestä, pidot viinasta selkehestä,

(Useita pareja hiipii ulos yht'aikaa.)

Verestä Herran miehen oman, verestä karitsan viattoman,


hääpidot Herran kansan!

(Sali on melkein tyhjentynyt. Soittajat ja laulajat ovat yiantilaan


vittauksesta poistuneet.)

Quia nominor dominicani


kuulkaa siis minun haukuntaani

(Olaus Hordinch ja muutamia naisia ja herroja hiipii ulos. Jää vain


Kaarina ja ritari Suomela, jotka ovat alkaneet kuiskailla toisilleen.)

maistellen herkkua taivahaista, kosk' ette palvelleet Pirua,


naista! Paastosin, kidutin ruumistani, kuoletin lihaani,
himojani.
KAARINA (on mennyt munkin luo ja ravistanut häntä kahden
viimeisen säkeen aikana käsivarresta.)

Isä, herätkäähän nyt jo toki!


Isä, herätkäähän nyt jo toki!

MUNKKI (avaa silmänsä ja iskee ne Kaarinaan.)

KAARINA (tarjoaa pikaria kädestään.)

Ehkä viinipikari vois teitä virvoittaa tuon suuren tuskan


jälkeen?

MUNKKI

Kuka olet, narttu, joka tarjoot synninmaljaa minun


juodakseni? Kestän niinkuin pyhä Antonius.

KAARINA

Tahdoin virvoittaa vain sua, isä, olen talon rouva, tunnet


minut.

MUNKKI (tuntee Kaarinan.)

Miehes suuren hurskauden vuoksi annan anteeksi sun


tarjoukses. — Näen sinut vieraan miehen kanssa! Joko
Herodiaan tavat sull? — Haluaisin puhutella miestäs', herra
Kuokkinaista, missä lienee?

KAARINA
Shakin peluuseen lie tästä mennyt
toisten herrain kanssa huoneeseensa. —
Menkää, menkää! Löydättehän sinne.
Siell' on Paavalikin sekä vielä
Jacob Hordinch ynnä Karpalanus…

MUNKKI (menee.)

KAARINA (kävelee etualalle.)

SUOMELA (seuraa häntä, pitäen kädestä.)

OLAUS (Kaarinan ja Suomelan huomaamatta ilmaantuu perälle.)

SUOMELA (Kaarinalle.)

Kätenne on mulle kallein aarre!

(Sutelee Kaarinan kättä.)

Köyhyyteni suuruutta vain suren, koska yhden elämän vain


voisin antaa suuteloista käsillenne!

(Suutelee Kaarinan molempia käsiä.)

Yö jo saapuu, oomme kahden kesken. Suojeluksen lupasin


ma teille. — Kätkeykäämme toisten näkyvistä. — Sairas
sieluin kaipaa balsamia sinun huuliesi, syleilysi. Turmioon ma
joudun ilman sua, samoin turmioon myös joudut sinä, ellet
suostu rukouksihini. — Moni ritar' vaanii kunniaasi. —

(Polvistuu.)

Vannon, rakastan sua! Jumalani!


KAARINA

Naimisiinhan emme voisi mennä!

SUOMELA

Sitähän en minä tarkoitakaan!

KAARINA

Meitä sitoo täällä monet suhteet. —


Neiti Sinikan te unhoitatte?

SUOMELA

Kaikki suhteet sitoo minut sinuun!

KAARINA

Täällä emme voisi yhdess' elää. — Kotianne ette voisi


jättää, — ettekä myös viedä mua täältä.

SUOMELA

Ymmärtäkää toki minut oikein! —


Vietätte — tään yön — te jonkun kanssa. —

KAARINA

Nähtävästi Hennekinin kanssa. —


Kiitos suojeluksen tarjonnasta!
Nouskaa, kutsun palvelijan tänne!
(Soittaa.)

SUOMELA (nousee.)

PALVELIJA (tulee.)

KAARINA (palvelijalle.)

Pyydä vieraat tulemahan sisään.


Paisti pöytään, kynttilöitä lisään!

PALVELIJA (menee.)

OLAUS (tulee.)

SUOMELA (Olaus Hordinchille, jonka huomaa noustessaan


permannolta.)

Tuopa aito merirosvon tapa: vaaniskella piilopaikastansa!

OLAUS

Vaaniskellut teit' en enkä ketään.

SUOMELA

Vaaniskelit mua, sinä konna!

(Paljastaa miekkansa.)

OLAUS (tekee samoin.)

KAARINA (väliin)
Pyydän, ettei verta vuodateta!

SUOMELA

Mua loukannut on tämä lurjus!

KAARINA

Loukannut ei sua eikä ketään!


Herra Olaus Hordinch mua lempii
ja myös minä häntä — ikuisesti. —
Käsi Hennekinin — sydän tämän.

SUOMELA

Syy sen suurempi on taistellaksein!

OLAUS (päättävästi,)

Kun on suuri syy, niin taistelkaamme!


Väistynyt en koskaan ennen. — Valmis!

SUOMELA

Tuohan kaulas tänne likemmäksi!


Listin poikki sen kuin nauriin naatin!

(Taistelevat, Suomela hyökkää silmittömästi. Olaus lävistää


Suomelan, joka kuolee. Ruumis jää lattialle.)

OLAUS (Kaarinalle, jota ottaa kädestä.)


Tule, tääll' ei oo nyt sinun paikkas —
eikä enää koskaan tästä lähtein.
Mennään, laiva purjeiss' oottaa meitä!

KAARINA (seuraa ääneti, pelästyneenä, estelemättä Hordinchia.


Menevät.
Häviävät taustalle.)

You might also like