100% found this document useful (1 vote)
94 views

Data And Process Visualisation For Graphic Communication A Handson Approach With Python 1st Edition Francesco Bianconi download

The document is about the book 'Data and Process Visualisation for Graphic Communication: A Hands-on Approach with Python' by Francesco Bianconi, which focuses on teaching graphic communication through data and process representation using Python. It is structured into two main parts: one covering data visualization techniques and the other focusing on process representation tools, complete with practical examples and Python implementations. The book is aimed at undergraduate students and professionals in various fields, providing a comprehensive guide to effective graphic communication.

Uploaded by

kholoduhk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
94 views

Data And Process Visualisation For Graphic Communication A Handson Approach With Python 1st Edition Francesco Bianconi download

The document is about the book 'Data and Process Visualisation for Graphic Communication: A Hands-on Approach with Python' by Francesco Bianconi, which focuses on teaching graphic communication through data and process representation using Python. It is structured into two main parts: one covering data visualization techniques and the other focusing on process representation tools, complete with practical examples and Python implementations. The book is aimed at undergraduate students and professionals in various fields, providing a comprehensive guide to effective graphic communication.

Uploaded by

kholoduhk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

Data And Process Visualisation For Graphic

Communication A Handson Approach With Python 1st


Edition Francesco Bianconi download

https://ebookbell.com/product/data-and-process-visualisation-for-
graphic-communication-a-handson-approach-with-python-1st-edition-
francesco-bianconi-57213600

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Ultimate Pandas For Data Manipulation And Visualization Efficiently


Process And Visualize Data With Pythons Most Popular Data Manipulation
Library Tahera Firdose

https://ebookbell.com/product/ultimate-pandas-for-data-manipulation-
and-visualization-efficiently-process-and-visualize-data-with-pythons-
most-popular-data-manipulation-library-tahera-firdose-57743098

Ultimate Pandas For Data Manipulation And Visualization Efficiently


Process And Visualize Data With Pythons Most Popular Data Manipulation
Library English Edition 1st Edition Tahera Firdose

https://ebookbell.com/product/ultimate-pandas-for-data-manipulation-
and-visualization-efficiently-process-and-visualize-data-with-pythons-
most-popular-data-manipulation-library-english-edition-1st-edition-
tahera-firdose-57725970

Ultimate Pandas For Data Manipulation And Visualization Efficiently


Process And Visualize Data With Pythons Most Popular Data Manipulation
Library English Edition 1st Edition

https://ebookbell.com/product/ultimate-pandas-for-data-manipulation-
and-visualization-efficiently-process-and-visualize-data-with-pythons-
most-popular-data-manipulation-library-english-edition-1st-
edition-57725974

Robust Quality Powerful Integration Of Data Science And Process


Engineering Jugulum

https://ebookbell.com/product/robust-quality-powerful-integration-of-
data-science-and-process-engineering-jugulum-9954414
Ibm Infosphere A Platform For Big Data Governance And Process Data
Governance Sunil Soares

https://ebookbell.com/product/ibm-infosphere-a-platform-for-big-data-
governance-and-process-data-governance-sunil-soares-51348126

Robust Quality Powerful Integration Of Data Science And Process


Engineering Hardcover Rajesh Jugulum

https://ebookbell.com/product/robust-quality-powerful-integration-of-
data-science-and-process-engineering-hardcover-rajesh-jugulum-7288354

Privacy And Data Protection In Software Services Services And Business


Process Reengineering 1st Ed 2022 Roberto Senigaglia Editor

https://ebookbell.com/product/privacy-and-data-protection-in-software-
services-services-and-business-process-reengineering-1st-
ed-2022-roberto-senigaglia-editor-33903782

Statistical Process Control And Data Analytics 8th Edition 8th Edition
John Oakland Robert Oakland

https://ebookbell.com/product/statistical-process-control-and-data-
analytics-8th-edition-8th-edition-john-oakland-robert-oakland-58376494

Process Simulation And Data Modeling In Solid Oral Drug Development


And Manufacture 1st Edition Marianthi G Ierapetritou

https://ebookbell.com/product/process-simulation-and-data-modeling-in-
solid-oral-drug-development-and-manufacture-1st-edition-marianthi-g-
ierapetritou-5353290
Francesco Bianconi

Data and
Process
Visualisation
for Graphic
Communication
A Hands-on Approach with Python
Data and
Process
Visualisation
for Graphic
Communication
Francesco Bianconi

Data and
Process
Visualisation
for Graphic
Communication
A Hands-on Approach with Python
Francesco Bianconi
Dipartimento di Ingeneria
Università degli Studi di Perugia
Perugia, Italy

ISBN 978-3-031-57050-6 ISBN 978-3-031-57051-3 (eBook)


https://doi.org/10.1007/978-3-031-57051-3

© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Switzerland
AG 2024
This work is subject to copyright. All rights are solely and exclusively licensed 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.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book
are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or
the editors give a warranty, expressed or implied, with respect to the material contained herein or for any
errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland

If disposing of this product, please recycle the paper.


To C. and C.
Preface

Graphic communication is a form of visual communication that employs images


and graphics to convey information, ideas, and messages. It plays a fundamental
role in several aspects of our personal and professional lives including education
and learning, science and research, brainstorming, and decision-making as well as
marketing and branding.
This volume aims at guiding the reader through the process of graphic com-
munication with particular focus on representing data and processes. It considers a
variety of common graphic communication scenarios among those that arise most
frequently in practical applications, e.g., representing magnitudes, proportions, re-
lations, groups, geographical data, timelines, etc.
Aimed at junior and senior undergraduate students in various technical, scien-
tific, and economic fields, this book can also be a valuable aid for researchers and
practitioners in data science, marketing, entertainment, media, and other fields.

How the Book Is Organized

The book is divided into two parts: representing data (Part I) and representing
processes (Part II). The first part deals with the graphical representation of data. It
starts with an introductory chapter on the types of variables, then guides the reader
through the most common data visualization scenarios, i.e., representing magnitudes,
proportions, one variable as a function of the other, groups, relations, and bivariate,
trivariate, and geospatial data. The second part covers various tools for the visual
representation of processes; these include timelines, flow-charts, Gantt charts, and
PERT diagrams.
In both parts each graphic communication task is considered independently in a
separate chapter which contains:

vii
viii Preface

• An introduction and analysis of the graphic communication task with particular


emphasis on the theoretical aspects such as the number and type of the variables
involved, the distinction between dimensions and measures, etc.
• A proposal of one or more visual communication tools for tackling the task, for
instance bar charts, pie charts, scatter plots, Gantt charts, and others
• Provision, for each tool, of one or more practical examples based on real data
and the corresponding implementation in Python
• Discussion of the technical details of the proposed implementation
The book also features four appendices which cover cross-chapter topics: mathe-
matics and statistics review, Matplotlib primer, color representation and usage, and
representation of geospatial data.

Figures, Data Listings, Scripts, Code Fragments, and Comment Boxes

For each example the book usually provides:


• One figure with the visual chart/plot we want to generate
• One or more Data listings reporting partial or complete views of the data used
to generate the chart/plot
• Either a Script or a Code fragment featuring the Python code used for creating
the chart/plot
• A comment box following each Script or Code fragment that explains the im-
plementation therein proposed
Note that Scripts are self-contained, executable Python scripts, whereas Code
fragments are snippets of code that cannot be executed separately: these are typically
used to show tweaks and changes to other scripts.

Companion Website

The companion website at www.graphic-communication-python.net contains


all the code and data needed to replicate the examples in the book, along with the
implementation specifics such as the versions of Python and of the packages used.

Prerequisites

Preliminary knowledge of Python at an intermediate level is not strictly necessary


but highly recommended. It is assumed, in particular, that the reader be familiar with
some common Python libraries such as NumPy and Pandas. But those who start from
scratch should not panic, as there are plenty of good resources out there to help them
Preface ix

out. Matthes’ crash course [1] is an excellent introduction to the language; Ramalho’s
Fluent Python [2] is a classic for those who want to take their skills to the next level.
Martelli et al.’s Python in a Nutshell [3] is also an amazingly deep yet accessible
desktop reference. For those who want to familiarize themselves with Pandas and
NumPy, McKinney’s Python for Data Analysis [4] is our recommendation.
Among the countless online resources we recommend Real Python [5], a platform
featuring tutorials, news, articles, and code examples for Python developers of all
levels.

Why Python?

At the time of writing Python is consistently ranked as the most popular programming
language in the world [6]. There are a number of reasons why it is so widely liked and
appreciated. Chief among them are its ease of use, its flexibility, and the presence
of an active and supportive community. The latter, in particular, is what makes it
possible to have tailored packages for nearly any kind of application in the most
disparate areas.
It is not uncommon to have a variety of Python packages for approaching the same
task, in which case the programmer will have to make a choice among the options
available. Graphic communication is no exception. As for data visualization, there
are already a number of packages available: Bokeh, HoloViz, Matplotlib, Plotly and
Seaborn are just some examples. In writing this book we therefore had to made a
choice about which package(s) to consider for the examples presented herein. We
initially decided to narrow the choice down to free tools only; consequently, paid
services such as PlotAPI are not discussed in this book. Then, for each type of chart
presented in the book, we proposed the implementation that we thought was the most
clear and concise. When there were substantially equivalent solutions, we favored
Matplotlib, both due to personal experience and the historical importance of this
library.
Our choice for the code was to keep all the Scripts self-contained and hence
separate from one another. The main advantage is that the reader can look at and
execute each script independently, without having to browse back and forth through
the book to find the missing parts. The downside, of course, is that there is some
code repetition: some parts (e.g., data loading and cleansing) are just copied and
pasted from one script to another. In a limited number of cases, when the difference
between two scripts was minor (by the order of two/three lines of code), we used
Code fragments to avoid excessive redundancy.
x Preface

Alternative Tools

As the title says, this book is tool-specific: our goal is not only to introduce the
reader to the theoretical aspects of graphic communication but also to provide
concrete solutions in Python, hence the “hands-on” in the title. There are, however,
many alternatives to Python including interactive, drag-and-drop tools as well as
other programming languages (see also [7] for an interesting discussion on this).
Microsoft Excel, Orange, Origin, and Tableau are examples of primarily in-
teractive solutions, although most of them also offer scripting capabilities. These
instruments typically have a low entry barrier, allowing anyone to quickly and eas-
ily create a bar or a line chart. That is particularly true when the usage is limited
to predefined template/models, but beyond that, customization and fine-tuning may
require some additional effort.
Among the programming languages JavaScript, MATLAB, and R are popular
alternatives to Python. Whichever the choice, the user will necessitate, in this case,
some background in coding and a comprehension of the different syntax and structure
(e.g., procedural vs. object.oriented) between the languages. There will probably be
a learning curve if you lack some background in coding; nonetheless, programming
languages usually provide significantly more flexibility and fine-tuning capabilities
than interactive tools.
Whether to favor interactive vs. code-based systems is essentially a matter of taste,
personal background, inclination, and not least the type of learner you are, whether
visual, reading/writing, kinaesthetic, or another type.

Perugia, Italy Francesco Bianconi


May 2024

References

1. Matthes E (2022) Python crash course, 3rd edn. No Starch Press, San Francisco
2. Ramalho L (2022) Fluent Python. Clear, concise and effective programming,
2nd edn. O’Reilly Media, Sebastopol
3. Martelli A, Ravenscroft AM, Holden S, McGuire P (2023) Python in a nutshell,
4th edn. O’Reilly Media, Sebastopol
4. McKinney W (2022) Python for data analysis: data wrangling with pandas,
NumPy, and Jupyter, 3rd edn. O’Reilly Media, Sebastopol
5. Real Python. https://realpython.com/. Accessed 6 Dec 2022
6. TIOBE (The software quality company). TIOBE Index for January 2024. https://
www.tiobe.com/tiobe-index/. Accessed 8 Jan 2022
7. Schwabish J (2021) Better data visualizations. A guide for scholars, researchers
and wonks. Columbia University Press, New York
Acknowledgments

Every book has a story of its own and the people who encouraged and assisted the
authors along the way. This one is no exception. A conversation with my colleague
and friend Antonio Fernández (Universidade de Vigo, Spain) got me started in this
project: I wish to thank him for encouraging me from the very outset of this journey. I
would also like to express my gratitude to Fabrizio Smeraldi (Queen Mary, University
of London, United Kingdom) and Stefano Saetta (Università degli Studi di Perugia,
Italy) for their valuable remarks and suggestions. A special thanks to the assistant
editors at Springer and to Springer itself for giving me the opportunity to publish
this book. Finally, I am grateful to Helena Meadows for her continued support and
critical eye on my choice for the charts’ presentation—I thank her sincerely.

xi
Disclaimer

Any data used in this book from third-party sources, including national and interna-
tional agencies, governments, or other organizations, does not imply endorsement,
recommendation, or approval by any of these bodies of the book’s content.

xiii
Contents

Part I Data

1 Introducing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 Types of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Measures and Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 Magnitudes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 Bar Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1 Basic Bar Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.2 Basic Bar Chart with Style Variations . . . . . . . . . . . . . . . . . . . 10
2.1.3 Paired Bar Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.4 Stacked Bar Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1.5 Multiple Bar Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.6 Horizontal Bar Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Packed Bubble Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3 Proportions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.1 Pie Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.1.1 Basic Pie Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.1.2 Pie Chart With Side Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1.3 Pulling Out the Wedges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.2 Doughnut Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.3 Semi-Doughnut Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.4 Waffle Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.4.1 Multiple Waffle Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.5 Hundred Percent Stacked Bar Charts . . . . . . . . . . . . . . . . . . . . . . . . . . 40

xv
xvi Contents

3.6 Divergent Hundred Percent Stacked Bar Charts . . . . . . . . . . . . . . . . . . 42


3.7 Tree Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.7.1 One-Level Tree Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.7.2 Two-Level Tree Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

4 One Variable as a Function of the Other . . . . . . . . . . . . . . . . . . . . . . . . . . 53


4.1 Line Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.1.1 Single-Line Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.1.2 Multi-Line Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.1.3 Split Line Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.2 Slope Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.2.1 Basic Slope Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.2.2 Slope Chart with a Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

5 Frequency Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.1 Histogram Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.2 Dot Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
5.3 Pyramid Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
5.4 Area Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.4.1 Single Area Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.4.2 Multiple Area Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

6 Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.1 Strip Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.2 Swarm Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.3 Box Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.4 Combined Box and Strip Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.5 Violin Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.6 Combined Violin and Box Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

7 Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.1 Chord Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.1.1 Directed Chord Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.1.2 Undirected Chord Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.2 Sankey Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7.2.1 One-to-Many Sankey Diagram . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.2.2 Many-to-Many Sankey Diagram . . . . . . . . . . . . . . . . . . . . . . . . 101
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Contents xvii

8 Bivariate Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107


8.1 Scatter Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.1.1 Basic Scatter Plot for Correlation Analysis . . . . . . . . . . . . . . . 108
8.1.2 Scatter Plot with Regression Line
and Confidence Interval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
8.1.3 Scatter Plot Matrix for Pairwise Correlation Analysis . . . . . . 112
8.1.4 Scatter Plot for Cluster Visualization . . . . . . . . . . . . . . . . . . . . 114
8.1.5 Scatter Plot for Cluster Visualization (Fancy Version) . . . . . . 116
8.1.6 The Datasaurus Dozen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

9 Trivariate Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123


9.1 Scatter Bubble Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
9.1.1 Simple Scatter Bubble Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
9.1.2 Scatter Bubble Plot with Annotations . . . . . . . . . . . . . . . . . . . 128
9.2 Lattice Bubble Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
9.3 Heat Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
9.3.1 Heat Map with a Color Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
9.3.2 Heat Map with Color Bar and Annotations . . . . . . . . . . . . . . . 137
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

10 Geospatial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141


10.1 Choroplet Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
10.2 Hexgrid Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
10.3 Proportional Symbol Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
10.4 Cartograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

Part II Representing Processes

11 Timelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
11.1 Horizontal timeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
11.2 Vertical Timeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

12 Flowcharts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
12.1 A Simple Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
12.1.1 Flowchart for Computing the Factorial of a Number . . . . . . . 171
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

13 Gantt Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175


13.1 A Simple Gantt Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
13.2 Gantt Chart with Activities and Phases . . . . . . . . . . . . . . . . . . . . . . . . . 178
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
xviii Contents

14 PERT Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183


14.1 AoN PERT Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
14.2 AoA PERT Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

A Mathematics and Statistics Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195


A.1 Set Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
A.1.1 Partial and Total Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
A.2 Correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
A.2.1 Pearson’s Linear Correlation Coefficient . . . . . . . . . . . . . . . . . 196
A.2.2 Spearmans’s Rank Correlation Coefficient . . . . . . . . . . . . . . . 196
A.2.3 Qualitative Interpretation of Correlation Coefficients . . . . . . 197

B Matplotlib: A Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199


B.1 Functional vs. Object-Oriented Interface . . . . . . . . . . . . . . . . . . . . . . . 199
B.2 Understanding Figure and Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
B.2.1 Adding Axes to a Figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
B.2.2 Generating Insets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
B.2.3 Customizing Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
B.2.4 Managing Titles and Subtitles Through mpl-ornaments . . . 206
B.2.5 Changing the Background Color of Figure and Axes . . . . . 208
B.3 Depth Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

C Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
C.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
C.1.1 Color Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
C.2 Guidelines for Using Colors in Charts . . . . . . . . . . . . . . . . . . . . . . . . . 215
C.2.1 When to Use Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
C.2.2 When Not to Use Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
C.3 Color Palettes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
C.3.1 Sequential Color Palettes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
C.3.2 Diverging Color Palettes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
C.3.3 Qualitative Color Palettes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
C.4 Specifying Colors in Matplotlib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
C.4.1 Transparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

D Geodesy and Cartography Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223


D.1 The World Geodetic System 1984 (WGS 84) . . . . . . . . . . . . . . . . . . . . 223
D.2 Map Projections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
D.2.1 Types of Projections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
D.2.2 Properties of Projections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Contents xix

D.3 Data Models for GIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229


D.3.1 Storing Geospatial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
D.4 Generating Maps With Python and GeoPandas . . . . . . . . . . . . . . . . . . 230

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Part I
Data
Chapter 1
Introducing Data

The aim of this first chapter is to briefly introduce data. We explain the distinction
between quantitative and categorical variables as well as ordered vs. unordered
variables. Additionally, the notions of dimension and measure are also presented.

1.1 Types of Variables

Data can be defined as pieces of information that can be collected, analyzed, and
used to gain knowledge and aid in decision-making. Concretely, data are collec-
tions of variables which represent any attribute or feature than can help distinguish
individuals, objects, or elements of any kind from one another [1].
As summarized in Fig. 1.1 variables come in different types. At the highest level
they can be classified into categorical and quantitative (the latter also referred to as
numerical in the remainder of the book).

Types of variables

Categorical Quantitative

Binary Non-binary Discrete Continuous

Fig. 1.1: Types of variables

Categorical variables answer the question "What type?" and the reply is always
a value from a finite set of predefined ones. Examples of categorical variables are
gender, country, province, nationality, make/brand, etc. If the set of predefined values
has only two elements the variable is said to be binary.

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2024 3


F. Bianconi, Data and Process Visualisation for Graphic Communication,
https://doi.org/10.1007/978-3-031-57051-3_1
4 1 Introducing Data

Quantitative variables answer the question "How much?" or "how many?" and can
be further categorized into discrete and continuous [2]. Discrete variables have values
in discrete sets, that is, sets where each element has a neighborhood containing only
that element (see also Appendix A.1 on this). Since discrete sets are either finite or
countably infinite [3], the natural way of generating discrete variables is by counting,
i.e., by recording how many times a certain event, element, or character occurs. A
continuous variable, by contrast, can take on an uncountable set of values: given
two values it is always possible to generate another value in between. Continuous
variables are generated by measurement.
Variables can also be ordered or not. We say that a variable is ordered when there
exists a total order on the set of all the possible values that the variable can take (more
about total and partial orders in Appendix A.1.1). We underline the fact that type of
variable (e.g., categorical vs. quantitative/numerical) and whether that a variable is
ordered or not are two distinct concepts. For example, it is a frequent assumption
that all univariate quantitative data are ordered. Though this is usually accurate, it is
not always the case. As an example consider color hue: albeit quantitative, this is not
an ordered variable (we cannot say that yellow is greater than green). We therefore
refer to ordered variables as the ones that possess a natural order, where natural
indicates some kind of intuitive, universally accepted ordering. None would object,
for instance, that height, weight, annual income, and pulse rate are ordered variables
in this sense. By contrast, we could sort some categorical variables such as gender
and nationality in alphabetical order, but this would be far from a natural ordering.
Besides, such an ordering would be language-dependent, hence arbitrary.
In the remainder of the book we shall denote variable types following the scheme
presented in Fig. 1.1. For the sake of simplicity we shall implicitly assume—unless
otherwise stated—that numerical variables are ordered and categorical ones are not.

1.2 Measures and Dimensions

Following the convention used in some data visualization tools (e.g., Tableau [4])
we consider data as composed of measures and dimensions.

• Measures represent quantities that can be measured or counted, and they are
usually expressed as numerical continuous or discrete variables. Samples of
measures are height, age, number of siblings, number of cars, etc.
• Dimensions are attributes that denote membership of a certain class/category,
and they are usually encoded as categorical or numerical discrete variables, e.g.,
country, region, year, month, etc. Dimensions are therefore variables that split
the measures into groups and subgroups determining the level of aggregation at
which the data are presented.
References 5

References

1. Rowntree D (2018) Statistics without tears: An introduction for non-


Mathematicians. Penguin UK, London
2. Ranganathan P, Gogtay NJ (2019) An introduction to statistics – data types,
distributions and summarizing data. Indian J Critical Care Med 23:S169–S170
3. Weisstein EW (2023) Discrete Set. From MathWorld–A Wolfram Web Resource.
Wolfram Research, Inc. Available Online at https://mathworld.wolfram.com/
DiscreteSet.html. Accessed 7 December 2023. Available from: https://mathworld.
wolfram.com/
4. Milligan JN (2016) Learning Tableau 10, 2nd edn. Packt, Birmingham
Chapter 2
Magnitudes

In this chapter we deal with the graphical representation of magnitudes over a set of
classes, where classes are identified by a categorical variable (e.g., country, province,
gender) or a numerical discrete one (e.g., year). We refer to a magnitude as the level
of some character of a class, and hence magnitudes are expressed as a numerical,
continuous, or discrete variable, for instance population, gross domestic product,
area, etc. The bar chart and its variations (paired bar charts, stacked bar charts)
are the mainstay in this context and are all presented in Sect. 2.1. Another option for
displaying magnitudes—packed bubble charts—is discussed in Sect. 2.2.

2.1 Bar Charts

Bar charts are one of the most fundamental tools for data visualization. The main
objective of this kind of chart is to compare magnitudes across classes (inter-class
comparison), although they can also be used to display frequency distributions (this
case will be treated in Chap. 5).
A vertical bar chart (just bar chart henceforth) reports classes on the horizontal
axis and magnitudes on the vertical axis, whereas in a horizontal bar chart it is the
other way round. In both cases the length of the bars is proportional to the magnitude
represented. When bar charts are used for comparing magnitudes it is good practice
to sort the bars by length in descending order: tallest bar on the left in a vertical bar
chart and longest bar at the top in a horizontal one. To illustrate the use of bar charts
we shall consider the gross domestic product (GDP) of the G7 countries in 2010 and
2020 (Data listing 2.1).

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2024 7


F. Bianconi, Data and Process Visualisation for Graphic Communication,
https://doi.org/10.1007/978-3-031-57051-3_2
8 2 Magnitudes

Data listing 2.1: Gross domestic product of the G7 countries in 2010 and 2020
broken down by sector. Values are in billions of USD. (Source: The World Bank [1].
Available under Attribution 4.0 International (CC BY 4.0))
Country,Year,Total,Agriculture,Industry,Manufacturing,Services
Canada,2010,1617.3,24.3,427.0,161.7,1062.6
France,2010,2645.2,42.3,470.8,272.5,1870.2
...
Italy,2010,2136.1,38.4,467.8,303.3,1416.2
...
USA,2010,15049.0,150.5,2904.5,1790.8,11482.4
Canada,2020,1647.6,28.0,397.1,150.4,1115.4
France,2020,2639.0,42.2,435.4,246.0,1879.0
Germany,2020,3889.7,31.1,1034.7,635.7,2462.2
...

2.1.1 Basic Bar Chart

The bar chart in Fig. 2.1 displays the total GDP of the G7 countries in 2020 (Data
listing 2.1). In this type of plot we have one measure (GDP value) and one dimension
(country).

Fig. 2.1: Basic bar chart (Script 2.1). Measure: GDP (bar height), dimension: country
(x-axis tick labels)
2.1 Bar Charts 9

Script 2.1 shows how to generate the bar chart in Fig. 2.1. The proposed imple-
mentation is based on Matplotlib’s Axes.bar().

Script 2.1: Generating a basic bar chart (Fig. 2.1)


"""bar_chart.py"""
import matplotlib.pyplot as plt
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

1 fig, ax = plt.subplots(nrows=1, ncols=1)

2 df = pd.read_csv(’data/gdp-g7-2010-2020.csv’, comment=’#’)

3 df = df[df[’Year’] == (year := 2020)]


df.sort_values(by=’Total’, inplace=True, ascending=False)

4 ax.bar(x=df[’Country’], height=df[’Total’])

5 title = f’GDP of the G7 countries in {year}’


subtitle = ’In bn USD. Source: The World Bank.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=25)

6 fig.savefig(’charts/bar-chart.png’, dpi=600, bbox_inches=’tight’)

Script 2.1 explained

1 Create a Figure with one sub-plot. Observe that, unless otherwise stated,
here and throughout the book we use Matplotlib’s explicit, object-
oriented interface (see Appendix B for details).
2 Read the GDP data.
3 Filter the data by year and sort by GDP in descending order.
4 Generate the bar chart. Arguments:

– x=df[’Country’] .→ Country names (horizontal position of the


bars—dimension)
– height=df[’Total’] .→ Bar height (displays total GDP—measure)

5 Place the title and subtitle.


6 Save the chart. Arguments to note:

– dpi=600 .→ Image resolution in dots per inch


– bbox_inches=’tight’ .→ Clip the unnecessary white space around
the figure
10 2 Magnitudes

2.1.2 Basic Bar Chart with Style Variations

We now introduce some tweaks in the code to make the chart look a bit more stylish.
Concretely, we remove all the spines from the frame but the bottom one, add borders
to the bars, and display the GDP value at the top of each bar (Fig. 2.2). The solution
is presented in Script 2.2. The first and last part of the code are the same as in
Script 2.1; therefore we shall not comment on them further.

Fig. 2.2: Basic bar chart with style variations (Script 2.2). Measure: GDP (bar height),
dimension: country (x-axis tick labels)

Script 2.2: Basic bar chart with style variations (Fig. 2.2)
"""bar_chart_with_style_variations.py"""
import matplotlib.pyplot as plt
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

fig, ax = plt.subplots(nrows=1, ncols=1)

df = pd.read_csv(’data/gdp-g7-2010-2020.csv’, comment=’#’)

df = df[df[’Year’] == (year := 2020)]


df.sort_values(by=’Total’, inplace=True, ascending=False)
2.1 Bar Charts 11

1 rects = ax.bar(x=df[’Country’], height=df[’Total’], linewidth=1,


edgecolor=’black’)

2 ax.bar_label(container=rects, padding=3)

3 ax.spines[[’top’, ’right’, ’left’]].set_visible(False)


4 ax.get_yaxis().set_visible(False)

title = f’GDP of the G7 countries in {year}’


subtitle = ’In bn USD. Source: The World Bank.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=60)

fig.savefig(’charts/bar-chart-with-style-variations.png’, dpi=600,
bbox_inches=’tight’)

Script 2.2 explained

1 Generate the bar chart and store the returned value (instance of
matplotlib.container.BarContainer) for later use (see point 2 ). Ar-
guments (see Script 2.1 for those not mentioned here):

– linewidth=1, edgecolor=’black’ .→ The edge width and color

2 Display GDP value at the top of each bar. Arguments:

– container=rects .→ The BarContainer representing the bars to


which the labels are to be added
– padding=3 .→ Distance between the GDP label and the top of each
bar (in pt)

3 Remove the top, left, and right spines.


4 Remove the y-axis ticks.

2.1.3 Paired Bar Charts

In Sects. 2.1.1–2.1.2 we have shown how basic bar charts can be used for inter-
class comparison of magnitudes. Paired bar charts enable both intra- and inter-class
comparisons. In this type of plot we have one measure and two dimensions: the bars
are grouped by position for the levels of the first dimension, while color and/or shade
denotes the second dimension.
The example in Fig. 2.3 is again based on the GDP data for the G7 countries (Data
listing 2.1). The purpose of this chart is to compare the GDP value by country in
2010 and 2020. In this case the GDP value is the measure; whereas country and year
respectively the first and second dimension.
12 2 Magnitudes

Fig. 2.3: Paired bar chart (Script 2.3). Measure: GDP (bar height and label), dimen-
sions: country (x-axis tick labels) and year (color)

Although the terms paired and grouped bar charts are used interchangeably in
practice, strictly speaking the first should be limited to those cases when the second
dimension is binary.
The implementation suggested in Script 2.3 has a relatively straightforward con-
cept: countries are represented by the x-axis ticks, and years by bars that are symmet-
rically positioned before and after each tick. To enhance readability we also include
horizontal grid lines, which is the visualization style recommended in [2].
This solution can be easily extended to sets of data where the second dimension is
non-binary (grouped bar charts). Keep in mind, however, that one potential problem
with grouped bar charts is clutter: too many bars can be confusing to the reader.
Therefore the use of this kind of chart with more than two bars per group should be
considered with care (see also [3, Chart types, paired bar] for a discussion on this).
2.1 Bar Charts 13

Script 2.3: Paired bar chart (Fig. 2.3)


"""paired_bar_chart.py"""
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

fig, ax = plt.subplots(nrows=1, ncols=1)

df = pd.read_csv(’data/gdp-g7-2010-2020.csv’, comment=’#’)

1 years = np.sort(df[’Year’].unique()); num_years = len(years)

2 sorted_indices = df[df[’Year’] == years[-1]][’Total’].argsort()[::-1]


countries_by_gdp = df[df[’Year’] == years[-1]].iloc[sorted_indices][’
Country’].to_list()

3 bar_width = 0.4

4 offsets = np.linspace(start=0, stop=bar_width*(num_years-1),


num=num_years)
offsets = offsets - np.mean(offsets)

5 x_ticks_pos = np.arange(df[’Country’].nunique())

6 for (year, offset) in zip(years, offsets):

7 x_pos = x_ticks_pos + offset

8 df_year = df[df[’Year’] == year]


df_data = df_year.iloc[pd.Index(df_year[’Country’]).get_indexer(
countries_by_gdp)]

9 ax.bar(x=x_pos, height=df_data[’Total’], width=bar_width,


label=f’{year:d}’)

10 ax.set_xticks(ticks=x_ticks_pos)
ax.set_xticklabels(labels=countries_by_gdp)

11 ax.legend(title=’Year’)

12 ax.grid(visible=True, which=’major’, axis=’y’)


13 ax.set_axisbelow(True)

ax.spines[[’top’, ’right’, ’left’]].set_visible(False)

title = f’GDP of the G7 countries in {years[-1]} and {years[0]}’


subtitle = f’In bn USD. Source: The World Bank.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=25)

fig.savefig(’charts/paired-bar-chart.png’, dpi=600, bbox_inches=’tight’)


14 2 Magnitudes

Script 2.3 explained

1 Sort the years, get the total number of years.


2 Sort the countries by total GDP value recorded in the last available year.
3 Set the bar width.
4 Compute the offsets to place the bars alternately to the left and right of
each x-axis tick (see point 7 ).
5 Define the position of the x-axis ticks.
6 Iterate through the years to create one set of bars for each year.

7 Place the bars symmetrically around each tick.


8 Select the data by year and country maintaining the same sorting
order defined in point 2 .
9 Draw the bars. Arguments:
· x=x_pos .→ The x coordinates of the bars
· height=df_data[’Total’] .→ The bar height (proportional to
GDP)
· width=bar_width .→ The bar width
· label=f’{year:d}’ .→ The label attached to the current set of
bars (to be displayed in the legend; see point 11 )
10 Set the position and labels of the x-axis ticks.
11 Set up the legend.
12 Add the horizontal grid lines.
13 Send the grid lines to the background.

2.1.4 Stacked Bar Charts

Stacked bar charts are an extension of the basic bar chart (Sect. 2.1) in which the
bars are broken down into segments (stacks) that represent fractional components
of the main category. The segments are highlighted by color and/or shade for easy
differentiation. The total length of each bar is the sum of the length of each segment;
therefore stacked bar charts are particularly useful to highlight the relative weight
of the categories within each bar [3]. Just like in paired bar charts, we have one
measure and two dimensions: in this case the first dimension usually denotes the
main category, and the second dimension a sub-category of the main one. Therefore
the first dimension differentiates one bar from another, the second dimension one
segment from another (within the same bar).
The example in Fig. 2.4 shows the GDP of the G7 countries broken down by
sector, i.e., agriculture, industry, manufacturing, and services. In this chart GDP is
the measure, country the first dimension, and economic sector the second dimension.
2.1 Bar Charts 15

Fig. 2.4: Stacked bar chart (Script 2.4). Measure: GDP (bar and stack height),
dimensions: country (x-axis tick labels) and sector (color)

One solution to generate this plot is to think of each group of GDP segments as
a separate bar chart sharing the same x- and y-axes with the other groups. We can
do this by repeatedly calling Matplotlib’s Axes.bar() and leveraging on the bottom
argument to adjust the vertical position of the bottom line (baseline) of each segment.
The implementation is described in Script 2.4.

Script 2.4: Stacked bar chart (Fig. 2.4)


"""stacked_bar_chart.py"""
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

fig, ax = plt.subplots(nrows=1, ncols=1)

df = pd.read_csv(’data/gdp-g7-2010-2020.csv’, comment=’#’)

df = df[df[’Year’] == (year := 2020)]


df.sort_values(by=’Total’, inplace=True, ascending=False)

1 gdp_sectors = [’Agriculture’, ’Industry’, ’Manufacturing’, ’Services’]

2 bottom = np.zeros(df[’Country’].nunique())
16 2 Magnitudes

3 for gdp_sector in gdp_sectors:


values = df[gdp_sector]

4 ax.bar(x=df[’Country’], height=values, bottom=bottom,


label=gdp_sector)

5 bottom = bottom + values

ax.legend(title=’Sector’)

ax.grid(visible=True, which=’major’, axis=’y’)


ax.set_axisbelow(True)

ax.spines[[’top’, ’right’, ’left’]].set_visible(False)

title = f’GDP of the G7 countries by sector in {year}’


subtitle = ’In bn USD. Source: The World Bank.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=25)

fig.savefig(’charts/stacked-bar-chart.png’, dpi=600, bbox_inches=’tight’)

Script 2.4 explained

1 Define the GDP sectors to include in the stacked bar chart.


2 Store the y coordinate of the bottom side of the segments here (baseline).
3 Iterate through the GDP sectors.
4 Draw the segments for the current GDP sector. Arguments:

– x=df[’Country’] .→ The horizontal position of the stacks


– height=values .→ The height of each segment
– bottom=bottom .→ The y coordinate of the bottom edge of each
segment (baseline)
– label=gdp_sector .→ The label that will be displayed in the legend
(denotes GDP sector)

5 Update the baseline.

2.1.5 Multiple Bar Chart

A multiple bar chart is conceptually equivalent to a stacked bar chart except the
segments making up each bar are pulled apart and placed into separate plots (Fig. 2.5).
The plots are arranged into a vertical array and the categories of the first dimension
2.1 Bar Charts 17

are maintained aligned. This layout facilitates the comparison of values across the
categories of the second dimension, in this case the GDP sector. More generally,
the approach of subdividing a chart into smaller sub-plots is referred to as small
multiples [3] and will be used in other parts of the book.

Fig. 2.5: Multiple bar chart (Script 2.5). Measure: GDP (bar height), dimensions:
country (x-axis tick labels) and sector (sub-plot + sub-plot label and color)

In the solution presented in Script 2.5 we first generate the sub-plots as place-
holders for the bar charts, then again use Axes.bar() to draw the bars.
Script 2.5: Multiple bar chart (Fig. 2.5)
"""multiple_bar_chart.py"""
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

df = pd.read_csv(’data/gdp-g7-2010-2020.csv’, comment=’#’)

df = df[df[’Year’] == (year := 2020)]


df.sort_values(by=’Total’, inplace=True, ascending=False)

gdp_sectors = [’Agriculture’, ’Industry’, ’Manufacturing’, ’Services’]


18 2 Magnitudes

1 grid_spec = {’hspace’:0.5}
fig, axes = plt.subplots(nrows=len(gdp_sectors), ncols=1,
gridspec_kw=grid_spec)

2 cpalette = [’#1f77b4’, ’#ff7f0e’, ’#2ca02c’, ’#d62728’]

3 max_val = df[gdp_sectors].max().max()

4 axes_gdp_sectors_and_colours = zip(axes, gdp_sectors, cpalette)

5 for ax, gdp_sector, colour in axes_gdp_sectors_and_colours:

6 rects = ax.bar(x=df[’Country’], height=df[gdp_sector], color=colour,


edgecolor=’black’)

7 ax.set_ylim([0,max_val])

8 ax.bar_label(container=rects, padding=3)

ax.spines[[’top’, ’right’, ’left’]].set_visible(False)


ax.get_yaxis().set_visible(False)

9 ax.text(x=1.0, y=1.0, s=gdp_sector, ha=’right’, va=’top’,


transform=ax.transAxes, color=colour)

10 for ax in axes.flatten()[:-1]:
ax.set_xticklabels([])

title = f’GDP of the G7 countries by sector in {year}’


subtitle = f’In bn USD. Source: The World Bank.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=55)

fig.savefig(’charts/multiple-bar-chart.png’, dpi=600, bbox_inches=’tight’)

Script 2.5 explained

1 Create one sub-plot for each GDP sector (see comments to Script B.3
for the meaning of grid_spec).
2 Define a qualitative color palette with as many colors as GDP sectors
(see also Appendices B–C for a discussion on color palettes and how to
define colors in Matplotlib).
3 Store the maximum value by GDP sector and country for uniform scaling
of the y axis (see point 6 ).
4 Zip sub-plots, GDP sectors, and colors into one iterable.
5 Iterate through the GDP sectors.
6 Draw the bar plot for the current GDP sector.
7 Adjust the y-axis scaling.
8 Show the GDP values at the top of the bars.
2.1 Bar Charts 19

9 Manually add the GDP sector label via Axes.text(). Arguments:

– x=1.0, y=1.0 .→ Coordinates of the text anchor point in the reference


system defined by transform.
– s=gdp_sector .→ The text to show.
– ha=’right’, va=’top’ .→ Position of the text with respect to the
anchor point (anchor point to the right and above the text).
– transform=ax.transAxes .→ The coordinates of the text anchor point
are given in the Axes reference system, hence x=1.0, y=1.0 corre-
sponds to the sub-plot’s top right corner.

10 Remove the tick labels from all the sub-plots except from the bottom
one.

2.1.6 Horizontal Bar Chart

Horizontal bar charts are simply vertical bar charts rotated by 90.◦ . There is no
conceptual difference between the two types of chart, except the horizontal ones are
preferable when the levels of the first dimension imply long category names. The
reason is that there is more room on the left-hand side of the chart to accommodate
the category labels [2, 4]. The horizontal bar chart in Fig. 2.6 is the rotated version
of the vertical bar chart presented in Fig. 2.1.
Matplotlib’s Axes.barh() enables easy generation of horizontal bar charts, as
shown in Script 2.6. Note that most parts of the code have already been explained in
the previous examples; therefore we shall not comment on them further.
Script 2.6: Horizontal bar chart (Fig. 2.6)
"""horizontal_bar_chart.py"""
import matplotlib.pyplot as plt
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

fig, ax = plt.subplots(nrows=1, ncols=1)

df = pd.read_csv(’data/gdp-g7-2010-2020.csv’, comment=’#’)
df = df[df[’Year’] == (year := 2020)]

1 df.sort_values(by=’Total’, inplace=True, ascending=True)

2 ax.barh(y=df[’Country’], width=df[’Total’])

ax.spines[[’top’, ’bottom’, ’right’]].set_visible(False)

ax.grid(visible=True, which=’major’, axis=’x’)


ax.set_axisbelow(True)
20 2 Magnitudes

title = f’GDP of the G7 countries in {year}’


subtitle = ’In bn USD. Source: The World Bank.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=10)

fig.savefig(’charts/horizontal-bar-chart.png’, dpi=600,
bbox_inches=’tight’)

Script 2.6 explained

1 Sort the GDP values in ascending order so as to have the longest bar at
the top of the chart.
2 Create the horizontal bar chart. Arguments:

– y=df[’Country’] .→ The y coordinates of the bars


– width=df[’Total’] .→ The bar length

Fig. 2.6: Horizontal bar chart (Script 2.6). Measure: GDP (bar length), dimension:
country (y-axis tick labels)
2.2 Packed Bubble Chart 21

2.2 Packed Bubble Chart

Packed bubble charts are another technique for comparing and visualizing magni-
tudes across levels of a dimension that is often represented by a categorical (usually
non-binary) variable. This kind of plot is composed of a set of circles (bubbles), one
for each category. The area of each circle is proportional to the value of the variable
to represent (measure), while color and label denote the category (dimension). The
plot is arranged in such a way that no two circles overlap, and some (or all) of them
are mutually tangent (hence the term ‘packed’).
The example in Fig. 2.7 shows how to use a packed bubble chart again to display
the GDP of the G7 countries in 2020 (Data listing 2.1). Note that the overall spatial
layout of the circles is irrelevant: we can change the relative position of two or more
circles without altering the information content of the chart.

Fig. 2.7: Packed bubble chart (Script 2.7). Measure: GDP (bubble area and label),
dimension: country (bubble color and label)

The implementation relies on the packed_bubble package [5] and is illustrated in


Script 2.7.
22 2 Magnitudes

Script 2.7: Packed bubble chart (Fig. 2.7)


"""packed_bubble_chart.py"""
import matplotlib.pyplot as plt
from matplotlib import colormaps
from matplotlib.colors import rgb2hex
import pandas as pd
from packed_bubbles import BubbleChart
from mpl_ornaments.titles import set_title_and_subtitle

1 fig, ax = plt.subplots(nrows=1, ncols=1, subplot_kw={’aspect’:’equal’})

df = pd.read_csv(’data/gdp-g7-2010-2020.csv’, comment=’#’)
df = df[df[’Year’] == (year := 2020)]
df.sort_values(by=’Total’, inplace=True, ascending=False)

2 df[’Labels’] = (df[’Country’] + ’\n(’ +


df[’Total’].map(’{:.1f}’.format) + ’)’)

3 cpalette = colormaps[’Set3’].resampled(lutsize=df[’Country’].nunique())

4 colour_codes = [rgb2hex(c) for c in cpalette.colors]

5 bubble_chart = BubbleChart(area=df[’Total’], bubble_spacing=0.0)

6 bubble_chart.collapse()

7 bubble_chart.plot(ax=ax, labels=df[’Labels’].to_list(),
colors=colour_codes)

8 ax.set_axis_off()

9 ax.autoscale_view()

title = f’GDP of the G7 countries in {year}’


subtitle = ’In bn USD. Source: The World Bank.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=100)

fig.savefig(’charts/packed-bubble-chart.png’, dpi=600,
bbox_inches=’tight’)

Script 2.7 explained

1 Create a Figure with one sub-plot. Arguments:

– subplot_kw={’aspect’:’equal’} .→ Set the same scaling for the x-


and y-axis to make the bubbles circular.

2 Generate the text that will appear in each bubble.


References 23

3 Get a predefined qualitative color palette (’Set3’) and downsample it to


have as many entries as countries.
4 Convert the entries of the color palette into a format compatible with
packed_bubbles (see also Appendix C on how to represent colors).
5 Create the bubble chart. Arguments:

– area=df[’Total’] .→ The area of the bubbles


– bubble_spacing=0.0 .→ The minimal space between the bubbles
after collapsing (we use 0.0 for tangent bubbles)

6 Collapse the bubbles toward the center of mass of the chart.


7 Display the chart in the target Axes. Arguments:

– ax=ax .→ The target Axes


– labels=df[’Country’].to_list(), colors=colour_codes .→ The
label and color of each bubble

8 Hide all the visual elements of the x- and y-axis.


9 Adjust the plot limits based on the content.

References

1. The World Bank (2023) World Development Indicators: Structure of value added.
Available Online at http://wdi.worldbank.org/table/4.2. Last Updated on 26 Oc-
tober 2023. Accessed 11 November 2023
2. Wilke CO (2019) Fundamentals of data visualization. Aprimer on making infor-
mative and compelling figures. 1st edn. O’Reilly Media, Sebastopol
3. Schwabish J (2021) Better data visualizations. A guide for scholars, researchers
and wonks. Columbia University Press, New York
4. Esselman A (2022) Which bar chart orientation should I use? In Storytelling with
data/You asked. Available Online at https://www.storytellingwithdata.com/blog/
2022/1/21/which-bar-orientation-should-i-use. Accessed 16 December 2023
5. Hunter J, Dale D, Firing E, Droettboom M, The Matplotlib development team.
Packed-bubble chart. Available Online at https://matplotlib.org/stable/gallery/
misc/packed_bubbles.html. Accessed 11 November 2022
Chapter 3
Proportions

The topic of this chapter is the visualization of proportions, that is, part-to-whole
relationships. We are therefore in the situation where the data can be partitioned
into a set of classes, for instance gender, nationality, age group, etc. The classes
are usually expressed as a categorical variable; the proportion values are expressed
as continuous variables with values in .[0, 1] or, equivalently, as percentages, with
the constraint that they sum to 1 (or 100%). In this type of chart we therefore have
one measure (representing a fraction or percentage) and usually one (occasionally
more) dimension. The general goal is to emphasize the relative importance of the
categories while also bringing the reader’s attention to each category’s portion of
the total. We present different tools for visualizing proportions; these include pie
charts, doughnut charts, waffle charts, hundred percent stacked bar charts, hundred
percent divergent stacked bar charts, and tree maps.

3.1 Pie Charts

Pie charts are one of the most popular types of plot for representing proportions.
A pie chart is a circle partitioned into radial slices (wedges) where each wedge
represents one class (Figs. 3.2, 3.3, 3.4). The arc length (hence the central angle
and area) of each wedge is proportional to the share of the corresponding class,
while color denotes category. Scottish statistician William Playfair is credited for
introducing pie charts for the first time at the beginning of the nineteenth century.
Figure 3.1 shows an early pie chart from Playfair’s Statistical Breviary [1].
In the following examples we show how to generate pie charts of the age dis-
tribution in the United States in 2022 (Data listing 3.1). In this situation we have
one measure (the proportion of each age group as a fraction of the total) and one
dimension, the age group (each age group represents one class).

© The Author(s), under exclusive license to Springer Nature Switzerland AG 2024 25


F. Bianconi, Data and Process Visualisation for Graphic Communication,
https://doi.org/10.1007/978-3-031-57051-3_3
26 3 Proportions

Fig. 3.1: Sample of an early pie chart from Playfair’s Statistical Breviary. (Source:
Wikimedia Commons [2], public domain)

Data listing 3.1: Age distribution in the United States, 2022. Population values are
in thousands, age groups in years. (Source: US Census Bureau [3], public domain.
Age groups modified from the original)
Age_group,Population
0-4,18539
5-14,41459
15-24,42266
25-34,44583
35-44,43190
45-54,40130
55-64,42178
65+,56193

3.1.1 Basic Pie Chart

Figure 3.2 shows an example of a pie chart based on the data reported in Data
listing 3.1. The implementation proposed in Script 3.1 relies on Matplotlib’s Axes.
pie().
3.1 Pie Charts 27

Fig. 3.2: Basic pie chart (Script 3.1). Measure: proportion (wedge area and label),
dimension: age group (color and label)

Script 3.1: Basic pie chart (Fig. 3.2)


"""pie_chart.py"""
import matplotlib.pyplot as plt
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

fig, ax = plt.subplots(nrows=1, ncols=1)

1 df = pd.read_csv(’data/age-distribution-usa-2022.csv’, comment=’#’)
df[’Percentage’] = 100*df[’Population’]/df[’Population’].sum()

2 df[’labels’] = (df[’Age_group’] + ’\n’ +


df[’Percentage’].map(’({:3.1f}%)’.format))

3 textprops = {’ha’:’center’, ’va’:’center’}


wedgeprops = {’linewidth’:1.5, ’edgecolor’:’white’}

4 ax.pie(x=df[’Population’], labels=df[’labels’].to_list(),
wedgeprops=wedgeprops, textprops=textprops, labeldistance=1.18)

title = f’Population of the United States by age group (2022)’


subtitle = ’Source: US Census Bureau.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=25)

fig.savefig(’charts/pie-chart.png’, dpi=600, bbox_inches=’tight’)


28 3 Proportions

Script 3.1 explained

1 Load the data and compute the percentage of each age group.
2 Generate the labels to show by each wedge.
3 Pack the style settings for the labels and wedges:
– textprops = {’ha’:’center’, ’va’:’center’} → Center the text
vertically and horizontally.
– wedgeprops= {’linewidth’:1.5, ’edgecolor’:’white’} .→ The
width and color of the wedge borders.
4 Create the pie chart. Arguments:
– x=df[’Population’] .→ The size of the wedges
– labels=df[’Age_group’] .→ The wedge labels
– wedgeprops=wedgeprops, textprops=textprops → The wedge style
– labeldistance=1.18 .→ The radial distance of the labels from the
center of the pie

3.1.2 Pie Chart With Side Legend

We now consider a variation of the pie chart presented in Sect. 3.1.1 in which the
labels are no longer displayed by the wedges but in a side legend (Fig. 3.3). The
procedure is exemplified in Script 3.2. Note that the first part of the code is the same
as in Script 3.1, and therefore it is not commented on further.
Script 3.2: Pie chart with side legend (Fig. 3.3)
"""pie_chart_side_legend.py"""
import matplotlib.pyplot as plt
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

fig, ax = plt.subplots(nrows = 1, ncols = 1)

df = pd.read_csv(’data/age-distribution-usa-2022.csv’, comment=’#’)
df[’Percentage’] = 100*df[’Population’]/df[’Population’].sum()

df[’labels’] = (df[’Age_group’] + ’ ’ +
df[’Percentage’].map(’({:3.1f}%)’.format))

wedgeprops = {’linewidth’:1.5, ’edgecolor’:’white’}

1 ax.pie(x=df[’Population’], labels=None, wedgeprops=wedgeprops)

2 fig.legend(labels=df[’labels’].to_list(), title=’Age group’,


bbox_to_anchor=(1,0.5), loc=’center right’,
frameon=False)
3.1 Pie Charts 29

title = f’Population of the United States by age group (2022)’


subtitle = ’Source: US Census Bureau.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=120)

fig.savefig(’charts/pie-chart-side-legend.png’, dpi=600,
bbox_inches=’tight’)

Script 3.2 explained

1 Create the pie chart. Proceed as in Script 3.1, but pass labels=None to
prevent the labels from being shown by the wedges.
2 Add the legend. Arguments:

– labels=labels → The labels.


– title=’Age group’ .→ The legend title.
– bbox_to_anchor=(1,0.5) → Position (x and y coordinates) of the
legend’s anchor point in the Figure space. The right border of the
legend will be aligned with the right edge of the figure (. x = 1.0),
and the legend will be centered vertically (. y = 0.5).
– loc=’center right’ → The position of the legend’s anchor point
with respect to the legend’s body.
– frameon=False .→ No frame around the legend.

Fig. 3.3: Pie chart with side legend (Script 3.2). Measure: proportion (wedge area),
dimension: age group (color)
30 3 Proportions

3.1.3 Pulling Out the Wedges

We can easily pull out one or more wedges from a pie chart by leveraging on the
explode parameter of Axes.pie(). This iterable specifies the extent by which each
wedge is moved away from the center of the chart in a radial direction. The values
are given as a fraction of the radius.
In Fig. 3.2 we pull the wedges of the last three age groups out of the pie. To
this end we modify Script 3.1 as shown in Script 3.3. Again, we refer the reader to
Script 3.1 for the parts of the code not commented on here.

Fig. 3.4: Pulling out the wedges (Script 3.1). Measure: proportion (wedge area and
label), dimension: age group (color and label)

Script 3.3: Pulling out the wedges (Fig. 3.4)


"""pie_chart_exploded.py"""
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

fig, ax = plt.subplots(nrows = 1, ncols = 1)

df = pd.read_csv(’data/age-distribution-usa-2022.csv’, comment=’#’)
df[’Percentage’] = 100*df[’Population’]/df[’Population’].sum()
3.2 Doughnut Charts 31

labels = list()
for _, row in df.iterrows():
labels.append(f’{row["Age_group"]}\n({row["Percentage"]:3.1f}%)’)

textprops = {’ha’:’center’, ’va’:’center’}


wedgeprops = {’linewidth’:1.5, ’edgecolor’:’white’}

1 offsets = np.zeros(len(labels));
offsets[-3::] = 0.05

2 ax.pie(x=df[’Population’], labels=labels, wedgeprops=wedgeprops,


textprops=textprops, labeldistance=1.18, explode=offsets)

title = f’Population of the United States by age group (2022)’


subtitle = ’Source: US Census Bureau.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=25)

fig.savefig(’charts/pie-chart-exploded.png’, dpi=600,
bbox_inches=’tight’)

Script 3.3 explained

1 Define the amount of the offset for each of the wedges we want to pull
out. Offset values are expressed as a fraction of the pie radius.
2 Create the pie chart and use the explode argument to pull out the last
three wedges by the amount defined in 1 .

3.2 Doughnut Charts

Doughnut charts are a graphical variation of pie charts with the main difference that
the overall shape is a ring instead of a circle (Fig. 3.5).
A small tweak to point 3 of Script 3.1 makes it very simple to create a doughnut
chart as shown in Code fragment 3.1. The key argument is ’width’:0.3 passed to
Matplotlib’s Axes.pie(), the effect of which is to set the radial width of the wedges
to 0.3, i.e., 30% of the pie radius.

Code fragment 3.1: Doughnut chart (modifies Script 3.1)


wedgeprops = {’linewidth’:1.5, ’edgecolor’:’white’, ’width’:0.3}
32 3 Proportions

Fig. 3.5: Doughnut chart (Script 3.1 as modified by Code fragment 3.1). Measure:
proportion, dimension: age group

3.3 Semi-Doughnut Charts

Semi-doughnut charts are essentially doughnut charts with half of the circle chopped
off. The original doughnut is usually cut in half horizontally, with the top half being
retained. This kind of plot is very common for representing the composition of
parliaments. In the following example we indeed consider the composition of the
House of Commons (United Kingdom) in 2022 (Fig. 3.6); the source data are shown
in Data listing 3.2.

Data listing 3.2: Composition of the House of Commons, United Kingdom, 2022.
Key to fields: Party = name of the political party; Abbreviation = abbreviation
by which the party is identified; Colour: color used for representing the party (see
also Appendix C). (Source: UK Parliament [4]. Contains Parliamentary information
licensed under the Open Parliament Licence v3.0. Colors added by the authors)
Party,Abbreviation,Seats,Colour
Conservative,CON,356,royalblue
Labour,LAB,196,red
Scottish National Party,SNP,44,yellow
Liberal Democrat,LD,14,orange
Others,Others,40,grey
Total,TOT,650,black
3.3 Semi-Doughnut Charts 33

Fig. 3.6: Semi-doughnut chart (Script 3.4). Measure: number of seats, dimension:
political party

Our procedure for creating a semi-doughnut consists of generating a doughnut


chart with a dummy wedge that extends across the lower half of the doughnut. The
dummy wedge is then removed leaving only the upper part of the chart visible.
Script 3.4 describes the implementation.

Script 3.4: Semi-doughnut chart (Fig. 3.6)


"""semi_doughnut_chart.py"""
import matplotlib.pyplot as plt
import pandas as pd
from mpl_ornaments.titles import set_title_and_subtitle

fig, ax = plt.subplots(nrows = 1, ncols = 1)

1 df = pd.read_csv(’data/uk-house-of-commons-2022.csv’, comment=’#’)

2 df[’labels’] = (df[’Abbreviation’] + ’ ’ + df[’Seats’].map(’{:d}’.format))

textprops = {’ha’:’center’, ’va’:’center’}


wedgeprops = {’linewidth’:1.5, ’edgecolor’:’white’, ’width’:0.4}

3 wedges, text = ax.pie(x=df[’Seats’], labels=df[’labels’].to_list(),


colors=df[’Colour’], wedgeprops=wedgeprops,
textprops=textprops, labeldistance=1.25)

4 wedges[-1].set_visible(False); text[-1].set_visible(False)

5 df = df[df[’Party’] != ’Total’]
legend = fig.legend(labels=df[’Party’], loc=’center’,
bbox_to_anchor=(0.5, 0.35), ncol=3, frameon=False)

title = f’Composition of the House of Commons, UK, 2022’


34 3 Proportions

subtitle = ’Source: UK Parliament.’


set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=25, v_offset=15)

fig.savefig(’charts/semi-doughnut-chart.png’, dpi=600,
bbox_inches=’tight’)

Script 3.4 explained

1 Read the data.


2 Let the labels show party abbreviation and seats.
3 Create the doughnut chart (see also point 4 of Script 3.1). Observe that:
– We get all the records in the dataset (Data listing 3.2), including the
’Total’ one—this makes up the dummy wedge. Note that the color
of the dummy wedge is irrelevant, as this wedge will be removed
(see point 4 ).
– We retrieve the returned values (wedges, text) for later use (see
point 4 ).

4 Hide the dummy wedge and its label.


5 Put up the legend showing all the entries except ’Total’.

3.4 Waffle Charts

A waffle chart, sometimes called a square pie or grid plot [5], is made up of a grid
of square or rectangular cells. Each cell in the grid represents a certain percentage
of the total data, while the grid as a whole represents the full data. Color and/or
shade indicates category, and categories are represented by clusters of contiguous
cells with the same fill. The number of cells in each cluster is proportional to the
share of that category to the whole. For easy understanding it is recommended to
select the total size of the grid to be a simple number (100 cells is a typical value).
The example in Fig. 3.7 again shows the distribution of the US population by age
group in 2022 (Data listing 3.1).
Observe that the discrete nature of this type of representation requires translating
the original data into a set of natural numbers (the number of cells of each class)
while maintaining the proportions among the classes similar to that of the original
data. This process is known as apportionment [6].
At the implementation level a waffle chart can be thought of as a variation of a heat
map (more on this in Sect. 9.3) with the following distinctive features: a) the color
palette is qualitative, b) color denotes classes, and c) cells denoting the same class
are contiguous. The solution presented in Script 3.5 relies on seaborn.heatmap(),
3.4 Waffle Charts 35

Fig. 3.7: Waffle chart (Script 3.5). Measure: proportion (number of squares of each
cluster; one square .≈1%), dimension: age group (color)

Seaborn’s [7] method for generating heat maps. For the apportionment we use
Voting [8], a Python library for election quotas, voting measures, and apportionment
methods.

Script 3.5: Waffle chart (Fig. 3.7)


"""waffle_chart.py"""
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
import pandas as pd
import seaborn as sns
import numpy as np
from mpl_ornaments.titles import set_title_and_subtitle
from voting.apportionment import huntington_hill as apportion

fig, ax = plt.subplots(nrows = 1, ncols = 1)

df = pd.read_csv(’data/age-distribution-usa-2022.csv’, comment=’#’)
df[’Percentage’] = 100*df[’Population’]/df[’Population’].sum()

df[’Labels’] = (df[’Age_group’] + ’ ’ +
df[’Percentage’].map(’({:3.1f}%)’.format))

1 cmap = mpl.colormaps[’tab10’].resampled(df.shape[0])
36 3 Proportions

2 grid = np.zeros(shape=(10,10))

3 df[’Apportionement’] = apportion(votes=df[’Population’], seats=grid.size)

4 grid_data = []
for idx in df.index:
grid_data.extend([idx]*df.iloc[idx][’Apportionement’])
grid = np.array(grid_data).reshape(grid.shape)

5 sns.heatmap(data=grid, ax=ax, linewidths=1.5, cmap=cmap, cbar=False)

6 ax.set_axis_off()
7 ax.set_aspect(’equal’)

8 handles = [Patch(color=cmap.colors[idx]) for idx in df.index]

ax.legend(handles=handles, labels=df[’Labels’].tolist(), ncols=1,


borderpad=1.2, bbox_to_anchor=(1.0, 0.5), loc=’center left’,
frameon=False, title=’Age group’)

title = f’Population of the United States by age group (2022)’


subtitle = ’Source: US Census Bureau.’
set_title_and_subtitle(fig=fig, title=title, subtitle=subtitle,
alignment=’left’, h_offset=102)

fig.savefig(’charts/waffle-chart.png’, dpi=600, bbox_inches=’tight’)

Script 3.5 explained

1 Select a qualitative color palette with as many entries as age groups.


2 Define a 10 .× 10 empty grid (the waffle).
3 Perform the apportionment, i.e., for each age group determine the num-
ber of squares proportional to the size of that group (see also Voting’s
documentation for details [8]). Store the results in a dedicated column
of the dataframe.
4 Populate the grid using the apportioned data. Suppose we have n cat-
egories (age groups) denoted as .C0, . . . , Cn−1 , and let . |Ci | indicate the
number of apportioned squares for the i-th class. After 4 the variable
grid will contain, in column-wise order: |C0 | contiguous elements with
value 0, |C1 | contiguous elements with value 1, and so on.
5 Generate the waffle chart (see also Script 9.4 for a comparison with heat
maps). Arguments:

– data=grid → The data (needs to be a rectangular array or a 2D


dataset that can be coerced into a rectangular array).
– ax=ax .→ The target Axes.
– linewidths=1.5 .→ The width of the lines that divide each cell (in
pt).
3.4 Waffle Charts 37

– cmap=cmap → The color map that defines the mapping from values
to color space.
– cbar=False .→ Do not draw a color bar.

6 Hide all the visual components of both axes.


7 Set the x- and y-axis to the same scale to create square cells.
8 Generate the color patches that will appear in the legend.

Please refer to the remarks on Scripts 3.1 and 3.2 for the parts of the code
not commented on here (particularly data reading and legend placement).

3.4.1 Multiple Waffle Charts

It is sometimes convenient to arrange multiple waffle charts into a matrix, a solution


which leads to a scheme in which we have two dimensions: the within-waffle and
the between-waffle one. This kind of layout is particularly effective when the within-
waffle dimension is binary, for instance when we want to show the fraction of a
population that has a certain character and how this fraction varies from one group
to another. In this case each waffle will have two clusters, respectively representing
the fraction of the population with that character and the fraction without.
As an example, Fig. 3.8 shows the percentage of tertiary-educated adult population
in the G7 countries. The chart is based on the data reported in Data listing 3.3. In

Fig. 3.8: Multiple waffle chart (Script 3.6). Measure: proportion of tertiary-educated
people (number of dark squares in each waffle; one square .≈1%), dimensions: being
tertiary-educated, yes or no (color), and country (waffle title)
Random documents with unrelated
content Scribd suggests to you:
heart without some strong doubt of the sincerity of the person he
has been conversing with.

"What is his object?" thought Dudley. "Does he really hope to


convert me by the mingled charms of his own eloquence, and the
fascination of my dear Eda's fortune?" He resolved, however, not to
display his real opinion of the arguments used, but to suffer the
worthy priest to pursue his own course and expose his own
purposes. "He must do it sooner or later," he said; "and then I shall
discover what is the meaning of this long discourse. In the mean
time, he cannot shake Eda's confidence in me, nor my love for her."

"I am happy to find," continued Dudley, aloud, "that such very


just and liberal views are entertained; for undoubtedly the
definitions of the Council of Trent have been one of the great
stumbling-blocks in the way of those persons who would willingly
have abandoned doctrines of which they are by no means sure, to
embrace others emanating from a church, the principal boast of
which is its invariable consistency with itself."

The priest looked at him with a doubtful and hesitating glance. He


was apprehensive, perhaps, of showing too much of the policy of the
church of Rome; and he stopped, as it was his invariable custom to
do when the expression of his opinions might do injury to the cause
he advocated, and no great object was to be obtained. He thought,
indeed, in the present instance, that something more might be
ventured; but yet he judged it more prudent to wait awhile,
calculating that if he managed well, growing passion might do the
work of argument; and after viewing, with Dudley, the little fountain,
he turned back to the house, directing his conversation to subjects
of a totally different character, grave but not ascetic, round which he
threw a peculiar and extraordinary charm. It was very strange the
fascination of his manner and conversation. When first its power was
felt by any keen and quick mind, one strove to grasp and analyze it,
to ascertain in what it consisted; but like those subtle and delicate
essences which chemists sometimes prepare, and which defy
analysis, something, and that the most important, that which gave
efficacy and vigour to the whole, always escaped. The words
seemed nothing in themselves: a little subtle, perhaps, somewhat
vague, not quite definite. The manner was calm and gentle, the look
was only at wide distant moments emphatic; but yet there was a
certain spirit in the whole which seemed to glide into the heart and
brain, unnerving and full of languor, disarming opposition,
persuading rather than convincing, wrapping the senses in pleasing
dreams rather than presenting tangible objects for their exercise. It
was like the faint odours of unseen plants, which, stealing through
the night air, visit us with a narcotic rather than a balmy influence,
and lull us to a deadly sleep, without our knowing whence they
come or feeling the effect till it is too late.
CHAPTER VIII.

Sir Arthur Adelon, after leaving Eda and Dudley together, hurried
back as fast as he could go to the house of Mr. Clive, passing by the
way the man who had brought him the note, which he still held
clasped firmly in his hand. He was evidently a good deal agitated
when he set out; the muscles of his face worked, his brow
contracted, and muttered sentences escaped his lips. From this state
he seemed to fall into deep thought. The emotions probably were
not less intense, but they were more profound; and when he came
near the house he stopped and leaned for a moment against the
gate, murmuring, "What can it be?" After a pause of a moment or
two he rang the bell, and asked the maid who appeared, where the
gentleman was who had sent him that letter. The woman seemed
somewhat confused, said she did not know anybody had sent him a
letter, but that Mr. Clive was in the drawing-room with his daughter.
Her embarrassment, and that of the baronet, however, were
removed, almost as she spoke the last words, by a voice calling
down the stairs and saying, "Sir Arthur Adelon, will you do me the
honour of walking up hither?"

The baronet instantly obeyed the invitation, but it was with a very
pale face, and the next instant he was in the room with Norries. The
latter had withdrawn into the chamber where his conference had
taken place with Clive, and he fixed a steadfast gaze on the baronet
as he entered; then turning towards the door, he closed it and
waved his visitor to a seat, taking one himself at the same time, and
still keeping his bright gray eyes fixed firmly upon the baronet's face.
Hitherto not a word had been spoken, and Norries remained silent
for some instants; but at length he said, "I perceive, both by your
coming and your demeanour, Sir Arthur Adelon, that you have not
forgotten me."

"Oh, no! Mr. Norries," replied the baronet; "I remember you quite
well, and am happy to see you. But is it not somewhat dangerous
for you to visit England just now?"

"Not in the least, I think," said Norries. "I am obliged to you for
your solicitude, Sir Arthur. If it had shown itself materially twelve
months ago, it might have kept me out of York Castle."

"I really do not see how I could have served you," answered Sir
Arthur Adelon; "indeed, I never knew that you were in York Castle."

"For three days," replied Norries, laconically. "But this is


irrelevant; let me speak of more important affairs. As your memory
is so good, you have probably not forgotten yet what took place
eight and six years ago, in regard to transactions affecting Charles
Dudley, Esquire, since dead."

"Well, sir, well!" cried Sir Arthur, "what of that?"

"You inquired once," said Norries, "for the correspondence


respecting that affair; I think I could give you some information
concerning it."

"Was it not burnt?" exclaimed Sir Arthur. "You told me it was


burnt."

"Pardon me, Sir Arthur," replied Norries; "I never told you any
such thing. My partner did, but he lied in this case as in many
others, and I, who knew little of the transaction at the time, found
the papers after his death, and have them safe in my possession."

There was some writing paper lying on the table, clean and
unsullied; but without knowing what he did, Sir Arthur Adelon took it
in his hands, and in two minutes it was twisted into every
conceivable shape. Norries gazed at him with the slightest possible
smile; and in the end he said, "I am afraid, Sir Arthur, that paper will
not be very serviceable; however, we can get more."

"Paha!" cried Sir Arthur Adelon; "let us think of serious things, Mr.
Norries. Those letters must be destroyed. Do you mean to say they
were all preserved?"

"Every one," answered Norries; "nay, more. I have spoken of


eight and of six years ago, but amongst the documents there are
several of a much earlier period, which show that the schemes then
executed had been long devising, that the purpose then
accomplished had been long nourished. The motives, too, are very
evident from certain passages; and I now tell you, Sir Arthur Adelon,
that if I had been made aware of the facts--of the whole facts--those
schemes would never have been accomplished, that purpose would
have been frustrated."

And he gazed sternly at the baronet, setting his teeth hard.

"My partner, Mr. Sherborne," continued Norries, after a pause,


during which his companion uttered not a word, but remained with
his eyes bent down, and his teeth gnawing his nether lip; "my
partner, Mr. Sherborne, was a great scoundrel, as you know, Sir
Arthur. In fact, you knew it at the time you employed him."

"No, sir, I did not," exclaimed Sir Arthur, catching at the last word.

"Yes, Sir Arthur, you did," replied Norries, firmly; "or you never
would have employed him in so rascally a business."

"He suggested to me everything that was done," replied the


baronet, eagerly.

"In consequence of a private conversation, of which he made a


note," rejoined Norries, "and of a letter, still preserved, so
confirmatory of the memorandum, that there can be no doubt of its
accuracy."

The face of Sir Arthur Adelon flushed. He was a man of one sort
of courage, and he replied, haughtily, "I think you intend to insult
me, sir. Beware what you are doing."

"I am quite aware," answered Norries, slowly inclining his head;


"neither do I intend at all to insult you, Sir Arthur. I speak truth in
plain terms, having learned in sorrow and adversity that such is the
only right course to pursue. In justice and in good faith I ought to
place the whole of those papers in the hands of a gentleman nearly
related to that Mr. Dudley--his son, I mean."

"It could do him no good," exclaimed the baronet; "the thing is


past and gone; he ruined and dead; nothing can by any farther
means be recovered. This Mr. Dudley, could not regain a shilling, nor
an acre of his father's property, as you well know."

"True," replied Norries; "there are some things in law which have
no remedy, as I do well know; but it is right that the son should
learn who ruined his father, and he should have known long ago, but
for one circumstance which may perhaps operate still farther."

"What is that?" demanded the baronet, quickly; "I have no


objection whatsoever to give a considerable sum for the possession
of those papers. They can be of no use to any one but myself.
Come, let us talk reasonably, Mr. Norries--let us say a thousand
pounds."

"Money will not do, here, sir," answered the other, in a


contemptuous tone; "it had its effect upon Mr. Sherborne, who was a
rascal; but it will have no effect upon his partner, who is an honest
man."

"Then what, in heaven's name, do you want?" demanded Sir


Arthur Adelon.
"To see you act up to your professions, Sir Arthur," replied
Norries. "At the election which began poor Mr. Dudley's ruin, and
which I had some share in conducting on your part, you professed,
and I really believe entertained--for I think that, in that at least, you
were sincere--principles of firm and devoted attachment to the cause
of the people. You declared that if they did but return you to
parliament, you would advocate all measures in favour of their rights
and liberties; you were more than what is called a Radical--you were
a Reformer in the true sense of the word; you gloried in being
descended from the old Saxon race; you pointed out that your name
itself was but a corruption of that of one of our last Saxon princes;
and you promised to do your best to restore to the people that
perfect freedom which is an inalienable inheritance of the Saxon
blood. You called your son Edgar, in memory of Edgar Atheling, and
you promised, in my hearing, to maintain those principles at all
times and under all circumstances, with your voice, with your hand,
with your heart's blood. Now, Sir Arthur, I call upon you to redeem
that promise; and if you do, in the way I shall point out, you shall
have those papers. I have kept them back from the person to whom,
perhaps, they ought justly to have been given, because I would not
blacken the name of one whom I believed to be a true patriot. I
found excuses for you in your own mind to excuse to myself my
retention of them. I knew you to be a man of strong passions under
a calm exterior; I knew that strong passions, whenever they become
masters, are sure to become despots; and I thought that you had
acted to the man we have mentioned, under an influence that was
overpowering--the influence of the strongest and most ungovernable
of all the passions: the thirst for revenge."

"Revenge!" exclaimed Sir Arthur. "Who told you I was moved by


revenge?"

"No one told me," answered Norries; "I knew it. I might have
read it in every line of those letters; I might have seen it in every
deed you did; but there was a portion of your previous history, Sir
Arthur, which I knew from my connexion with that part of the
country, and which when once the machinations were exposed to my
view, afforded the key to all. I ask you, Sir Arthur Adelon, whether
some six or seven-and-twenty years ago, Mr. Charles Dudley did not
carry off from your pursuit, the lady on whom you had fixed your
heart?"

Sir Arthur Adelon's usually placid face assumed the expression of


a demon; and no longer averting his eyes from the fixed, stern gaze
of Norries, he stared full in his face in return, and slowly inclined his
head. He said not a word, but that look and that gesture were
sufficient reply. They said, more plainly than any words could have
spoken, "You have divined it all; you have fathomed the dark secret
of my heart to the bottom."

"Well, Sir Arthur," continued Norries, with a softened air, "I can
excuse strong passions, for I have them myself, and I know them at
times to be irresistible. In your case, I was sure you had been thus
moved. I looked upon you as a man devoted to the service of your
country; and I thought that, in a case where all other considerations
should give place to the interests of my country, it would be wrong
to damn for ever the name of one who might do her the best and
highest of services. There was but one thing that made me doubt
your sincerity."

"You should not doubt it," said Sir Arthur; "I am as sincerely
devoted to the service of my country as ever."

"It is your general sincerity to which I allude," said the plain-


spoken Norries; "and the reason why I doubted it is this. When you
had effected your purpose--when you had ruined an honest and
good man, though a Norman and an aristocrat--you did not boldly
and fearlessly leave him to his fate; you afforded him assistance to
save a pitiful remnant of his property, and affected benevolence and
kindness to a man you hated. I understand it all, Sir Arthur; it was
not unnatural, but it was insincere."
"We had been upon good terms for many years," replied the
baronet, who had now resumed his usual demeanour.

"Good terms!" repeated Norries, with a laugh; "well, be it so. You


are now keeping up the appearance of good terms with the
government which you then opposed, and of which you spoke in
language certainly seditious, as it is called, and perhaps treasonable.
These things have created a doubt. That doubt must be removed,
not by words and professions, not by appearances and pretences,
but by acts."

"Speak plainly," said Sir Arthur Adelon. "What is it that you want?"

"There is a meeting to be held at twelve o'clock this night in the


little town of Barhampton," said Norries, "where several gentlemen,
entertaining precisely the same sentiments which you expressed
some eight years ago to the people of Yorkshire, are to take into
consideration what decisive measures can be adopted for obtaining
those objects which you then professed to seek. I require that you
should then join us, and be one of us."

"Impossible!" cried Sir Arthur Adelon, with a look of consternation


and astonishment. "Would you have me attend a seditious meeting
at midnight with a man who has fled from the course of justice--I, a
magistrate for the county?"

A bitter smile came upon the lip of his companion; but he replied
immediately, "Even so! I would, indeed, Sir Arthur. The spirit of
patriotism is not so strong in you, it would seem, as the spirit of
revenge, or you would not hesitate. But thus much, to end all, one
way or the other: you either come, and, if you do come and frankly
join us, without any insincerity, receive the papers I have mentioned;
or you stay away, and Mr. Edward Dudley receives them."

"This is unfair!" exclaimed Sir Arthur Adelon.


"Unfair!" replied Norries; "how unfair, sir? I acting according to my
conscience, however you may be acting. My only reason for
withholding these letters from the person who would have a right to
possess them, if their suppression were not necessary to the service
of my country, is because I trust that you, whose name and station
may be an infinite advantage as a leader of the people hereafter, will
put yourself in that position in which no want of moral courage, no
vacillating hesitation can be shown, or would be possible. If you
refuse to do so, you will take from me my only motive for not giving
them to him who will know how to use them rightly. You will show
yourself as insincere in your professions of patriotism as you were
insincere in your professions of friendship; and I shall then regard
you with contempt, and treat you without consideration."

There was a stern and commanding energy in his manner which


crushed down, as it were, in the breast of Sir Arthur Adelon the
angry feelings which his impetuous words aroused. He felt cowed in
the presence of the bold, fearless man who addressed him. He
remembered, in former times, several traits of his decision and
unhesitating vehemence; and he felt sure that he would do as much
or more than he said. At first, indeed, anger was predominant; he
gathered himself up, as it were, for a spring; but his heart failed
him, and he said in a mild tone, "You are too fierce--you are too
fierce! Let me consider for a moment how this can be arranged. I
am as willing as any one to make sacrifices for my country's
advantage; but first you take me by surprise, next you use words
and proceed in a manner which are little likely to induce me to trust
to your guidance."

He thought he had got an advantage, and he was proceeding,


gradually resuming a tone of dignity, when Norries stopped him,
saying, "Sir Arthur Adelon, there are times and circumstances which
of themselves, and in their own pressing nature, abridge all
ceremonies. If your house were on fire, and you in danger of
perishing by the flames, I should not wait for the punctilios of
etiquette, but should wake you roughly, saying, 'Run, run, save your
life and your family!' Sir, I tell you England is on fire, and the time is
come for all men to choose their part. The days of weak indifference
are over. Now is the time for decision and action; but nevertheless, I
will not leave you any excuse, but humbly entreat you to come to
our meeting to-night, and support with your presence, and your
voice, and your influence, those principles which you have asserted
warmly on other occasions."

"But it may be very difficult to manage," said Sir Arthur Adelon; "I
have guests in my house, whom I cannot in courtesy leave without
some exceedingly good excuse. I am not accustomed to go out at
such hours of the night, and to do so will certainly appear very
suspicious, especially under existing circumstances."

"All that will be easily arranged," answered Norries. "You are a


magistrate, you say, and may consequently be called upon at any
hour on pressing occasions. You do not, of course, communicate to
your family or your guests the exact business which calls you forth,
or the motives for going at one hour rather than another; but should
anything more be wanting to smoothe the way for you, I will
presently write you a note, calling upon you to be at Barhampton to-
night at twelve, on matters of importance. I do not think," he added,
with a sneering smile, "that even your confessor will venture to
cross-question a gentleman of your independence upon a business
with which he has nothing to do."

"Certainly not," replied Sir Arthur Adelon; "and I have no


objection to come; but I cannot bind myself to anything till I hear
upon what measures your friends decide."

"Nor can I bind myself to anything, then, till I hear upon what you
do decide," rejoined Norries. "The papers are yours whenever you
act up to your professions. I shall ask nothing more, Sir Arthur. I
have a copy of your speech upon an occasion which you well
remember; I will require nothing more of you than to fulfil the
pledges therein given, and the moment you prove you are ready so
to act, I resign into your hands those letters, of which others might
not judge so favourably as I am inclined to judge. Do you promise to
come?"

"I do," answered Sir Arthur Adelon, in a firmer tone than he had
hitherto used, but with a certain degree of bitterness too. "Yet,
Norries, there are various other thoughts and considerations of deep
moment, which our conversation of to-day suggests. It revives in me
the memories and feelings of past years. You should have
considered that these matters had passed away from my mind for a
long time; that of the plans, and hopes, and schemes, and passions
of those times, some have been accomplished or gratified, and have
been well nigh forgotten; some, from the utter hopelessness of
seeing them accomplished, have faded away, and become more like
a vision than a reality. What will not a man do when he is eager and
excited with the vehement impulse of fresh feelings and sharp
discussions, and the enthusiasm of those who surround him? But
take those accessories away, and the purposes themselves fall into a
sleep from which it requires some time and preparation to arouse
them into active and energetic being again. You should have
considered this, and not pressed me so eagerly without some
preparation."

"Perhaps I should," replied Norries; "but, Sir Arthur, you have


known me long, and have known me to be a brief and abrupt man.
My purposes never sleep; my objects never fade: the one engrossing
object of my country's fate and the welfare of my fellow-men is
never a passing vision to my eyes, but a stern reality ever present,
so that I am little able to comprehend the hesitations of other men."

Sir Arthur Adelon, while the other spoke, had cast down his eyes
thoughtfully, as if little attending to the words of his companion; but
when he ceased speaking, he said, in an abstracted manner, "This
Dudley, too, he has intruded himself into my family. He is now at
Brandon, as you have doubtless heard. The cold, icy hand seemed to
seize my heart again when I saw him. I felt as if the spawn of the
viper were before me, and as if it were destined that the race were
to survive and poison my peace, even when the reptile that first
stung me was crushed."

Norries gazed at him steadfastly, with his brow contracted with a


steady, contemplative, inquiring look; and then he replied, "I do
beseech you, Sir Arthur Adelon, to banish such thoughts, to let the
faults of the dead, if faults there were, rest with the dead. I think
you believe in a God, do you not? Well, sir, there is a God who will
judge him and you. He is gone to receive his judgment; the time will
come, ere long, for you to receive yours. In the mean while, injure
not one who has never injured you, and pursue this fell and heinous
vengeance no further against the son of one whom you once loved--
--"

"And of one I always hated," answered the baronet, finishing the


sentence for him. "But do you not know, Norries, that as the
sweetest wine turns soonest to vinegar, so love, wronged and
despised, changes to the bitterest hate; as for the rest, I purpose
pursuing no vengeance against the young man. I wish he would quit
my dwelling, for the very feeling of being obliged to maintain a
courteous and soft demeanour towards him, increases the loathing
with which I regard him. That is all--that is all, I assure you; I would
do him no harm--but I love him not, nevertheless."

"I can see that, Sir Arthur Adelon," answered his companion; "and
I see, moreover, a dark and sinister fire in your eyes, which I
observed once before, when first in my presence you mentioned the
name of Mr. Dudley to my partner. There were deeds followed that
mention, which I need not call to your mind. I trust there will be
none such now--nay, nor any attempt towards them; if there be, I
will prevent it. I am not so good a lawyer--indeed, I know but little
of the trade--I am not so good a lawyer as Mr. Sherborne, but I am a
bolder, more resolute, and more honest man. However, I shall see
you to-night. Is it not so?"
"Undoubtedly," answered Sir Arthur Adelon; "but you have not yet
told me where I shall find you in Barhampton."

"You had better go to the little inn--the Rose, I think it is called,"


replied Norries; "there is but one. There some one shall come to
lead you to us; for we are upon our guard, Sir Arthur, and resolute
neither to be taken unawares, as some men have been, nor to act
rashly, and bring down destruction on our own heads, as those
thoughtless, weak, and poor-spirited men did in Yorkshire."

"I am very happy to hear it," said the baronet, in a tone of


sincerity. "I will be there somewhat before twelve; till then,
farewell." And shaking Norries by the hand with every sort of
apparent cordiality, he left him, and returned to Brandon. But when
he had re-entered the house, he retired for some time to the library,
not to consider his future conduct, not to review the past. It was, in
truth, that the conversation of that morning had aroused within him
feelings dark, bitter, and deadly, which had slept for years; and he
felt he could not see Mr. Dudley without calming himself, lest
sensations should appear which he wished studiously to conceal
from every eye.

CHAPTER IX.

With a quiet, cat-like watchfulness, Mr. Filmer remarked


everything which passed between Eda Brandon and Charles Dudley.
It was not words that he laid in wait for, but looks and gestures, the
involuntary as well as the voluntary, the trifling as well as the
important. Nothing escaped him, not even the accidental trait or the
slightest possible indication of a passing emotion. Not the quick
glance of the eye, withdrawn as soon as given, not the trembling
hand nor the quivering lip, not the irrepressible sigh; not the fit of
absence and the sudden raising of the look to the loved one's face,
was unremarked by one who knew human nature well, and had
made a trade of observation. "They love," was his conclusion, "and
they understand each other. That walk home has concluded what
seems to have been begun long ago. Now, then, what good is to be
derived from this affair?"

It is a common calculation which he made, but one very apt to


mislead. Men who see others labouring for the gratification of their
passions, are often tempted by the opportunity to endeavour to rule
them for their own purposes, and then, whatever event occurs, they
ask, "What good is to be derived from this affair?" But they often
miscalculate, because they do not ask themselves also, "Is there
anything to be made of it, with honour and honesty?" If they did
they might succeed where they every day fail.

Mr. Filmer, however, had his own particular views, which led him
upon one peculiar course. His very position gave a direction to all his
actions. The Roman priest stands alone amidst the world, separated
from all the dearest ties of our nature by an irremovable barrier. He
may have sympathies, but they are curtailed and restricted; he may
have affections, but they are limited and enthralled. One
predominant object is ever before him: one career is fixed for his
efforts. He stands alone in the world, I repeat, not so much the
servant of God as the servant of a hierarchy, to the interest and
advancement of which all his energies must be devoted, and for
whose purposes all his talents must be employed. As long as he can
bring the satisfaction of affections, and the gratification of any
passions, within the circle to which the whole course of education
from his earliest years has restricted his consciousness of duty,
perhaps they may be more strongly--I had almost said more fiercely-
-exercised, from the very fact of their narrow range; but the moment
they would go beyond that limit, the petrifying influence of an
engrossing church comes in, and changes the man into the mere
representation of a system.

Such was the situation of Mr. Filmer. He was by no means without


passions: fiery, eager, impetuous; but they were subdued to the one
strict rule, and setting out with that mighty conquest, it was in
general more easy for him to subdue the minds of other men also.
He was not without considerable abilities--abilities approaching
genius. He might have been a great man, in short, if he had not
been compelled to be an artful man. But for a priest of that church,
in the midst of an adverse population, it is impossible to be
otherwise. It is not a religion of openness and candour; and its
means must be covert, its course tortuous and indirect. Even in the
very case of Mr. Dudley, his passions were not quiescent; but he was
prepared to sacrifice all personal feeling for the one great object of
his existence, and he watched, as I have said, asking himself, "To
what uses the events taking place could be applied?"

It was not, however, Dudley alone whom he watched, nor Dudley


and Eda. Sir Arthur Adelon was also an object of attentive
consideration during the evening. There was something in his
manner which showed the keen eye of the priest that the mind was
not at ease: that there was something working within the baronet's
bosom; and he was surprised that it was not revealed to him at
once, for the secret of Sir Arthur Adelon's thoughts was not often
concealed from him. The whole of his past life had been displayed
before Filmer's eyes, and much which had been taking place had
been discussed again and again between them. So far there was
nothing to be concealed; and the priest marvelled that, if anything
had gone wrong in the course of Sir Arthur's morning expedition, he
could sit for several hours without communicating the fact to him.

Sir Arthur, however, paused and hesitated; not that he feared at


all to recur to the past, but it was his yet unconfirmed purposes for
the future which he hesitated to reveal. He knew that Filmer was a
firmer, more resolute man than himself; he doubted that he would
approve any, even the slightest, concession to fear. That he was
politic and skilful he knew, and that his policy and skill would be
exercised in his patron's behalf he was also fully convinced. But
there was a dread upon him; and he apprehended that the priest
would advise measures too bold for his nerves at that time. If he
had been forced into vigorous defence, Sir Arthur would have sought
his advice at once; but there was a choice of courses before him; he
hesitated: hesitation is always a weakness, and as such is sure to
take the weaker course. Twice, however, during the evening, he
caught Filmer's eye resting upon him with a very inquiring look. He
judged that he suspected something, and therefore he resolved in
the end to tell him a part; to show him a half-confidence; deceiving
himself, as all men in such circumstances do deceive themselves,
and believing that he could to a certain extent deceive Mr. Filmer
also, although he had known that clear-sighted and penetrating man
for seven-and-twenty years.

The dinner passed most cheerfully with all but Sir Arthur Adelon.
Lord Hadley was in great spirits; and, seated next Eda, he made
himself as agreeable as moderate talents, gentlemanly manners, and
no very decided character would admit. Dudley was calm, by no
means so gay as his young companion; but yet the happiness that
was in his heart, like a lamp within an alabaster urn, spread light
and cheerfulness over all. Mr. Filmer was, as usual, composed and
tranquil in his manner; at times impressive in his language, but often
adding to the gaiety of others by a quiet jest or epigrammatic reply,
which derived additional force from his seeming unconscious of its
possessing any. Eda left the table very soon after the dessert had
appeared. There were those things in her bosom which made her
feel happy in the solitude of her own chamber. Thought, calm,
uninterrupted thought, was at that moment very sweet to her. She
loved and was beloved; and she had the grand satisfaction of feeling
that she had it in her power to raise one to whom her affections had
been given for years, who possessed her highest esteem, and who
she knew well deserved high station, from unmerited misfortunes to
the position which he was born to ornament. It was indeed a
blessing, and Eda went and pondered upon it till her eyes filled with
pleasant tears.

For about a quarter of an hour after she had gone, Sir Arthur
Adelon continued at the table, passing the wine with somewhat
nervous haste, and keeping up a broken conversation from which his
thoughts were often absent. At length he said, speaking across the
table, "Filmer, my reverend friend, I wish to speak with you for a few
minutes: Lord Hadley, Mr. Dudley, you must not suffer the wine to
stand while we are absent; I shall be back almost immediately." And
he led the way out of the room.

Filmer followed him with a quiet smile, saying to himself, as he


walked along towards the library, "What men do timidly they always
do awkwardly; in that they are different from women, in whom
timidity is grace. Adelon has had twenty opportunities of speaking to
me, and has of course chosen the worst."

"Well, Filmer," said the baronet, almost before the door was
closed, "I have something to talk to you about of great importance."

"I thought so, Sir Arthur," answered Mr. Filmer. "What is it?"

"Why did you think so?" inquired his friend, somewhat surprised,
and somewhat apprehensive.

"Because it seemed to me that you had been annoyed at


something," replied Filmer. "When you are uneasy, Sir Arthur, it is
soon perceived; too soon, indeed. The young and unobserving may
not remark such things, but one who has been, I trust I may say,
your friend for so many years, can perceive when you are uneasy in
a moment; and a very shrewd judge of men's feelings and actions,
which I do not pretend to be, would, I doubt not, discover the
uneasiness, even without having had the advantage of such long
acquaintance."
These words, as he intended, added to the embarrassment which
Sir Arthur already felt; but nevertheless he pursued his course,
endeavouring, as far as possible, to conceal that he had any
concealment. "Well, Filmer, well," he said, "men cannot alter their
natures, you know; and the matter is one which might well cause
uneasiness. You recollect that affair of Charles Dudley? You do not at
all doubt that this is his son who is here?"

"No," answered Mr. Filmer, drily; "but we knew that last night. I
certainly did, from the moment I saw the back of his head, and your
face left no doubt that you had made the same discovery."

"The very first sight of him," answered Sir Arthur Adelon, bitterly,
"and the feelings which that sight produced, left me no doubt of who
it was that stood before me. But listen a moment, Filmer--listen a
moment. There is much more behind. You remember well that
business of Charles Dudley, I say, of him who was my friend and
companion, my rival and my enemy, and last, my acquaintance----"

"And your victim," murmured Filmer, in so low a tone that Sir


Arthur Adelon did not remark the words, but added, "and my debtor.
You doubtless also remember the election which we contested, and
my lawyers, Messrs. Sherborne and Norries?"

"Perfectly," answered Filmer; "the one the soul of policy and


intrigue; shrewd, penetrating, subtle, and faithless; the other, the
incarnation of republican energy and determination, rash and
inconsiderate, though full of vigour and ability. He was implicated a
short time ago in the Chartist insurrection, apprehended with his
fellows, if I remember right, and thrust into York jail----"

"Whence he made his escape in two or three days," rejoined Sir


Arthur Adelon. "It would be a strong prison that would keep him in.
However, Sherborne is dead; Norries alive, well, and in this country."

"That is no great matter, then," answered Mr. Filmer. "Sherborne


was the dangerous man, and he is gone. All your communications
were with him, my good friend; at least as far I know, and I think I
saw every letter."

The words, "I think," were spoken in a somewhat doubtful tone,


as if he did not feel quite sure of the extent of Sir Arthur's
confidence; but the baronet replied, eagerly, "Every one, Filmer; and
indeed, as you well know, many of them were dictated by yourself."

"True!" said the priest--"true! I am happy to say they were; I say


I am happy, Sir Arthur, because it was but right that that man should
receive a check. Not contented with marrying a lady of the only true
church, who was promised by her relations to one of their own just
and reasonable belief, he perverted her from the path of truth into
that of error, and in twelve months had filled her mind with all the
foulest doctrines of that heresy in which he had himself been
brought up. It was just and right, Sir Arthur, that he should not be
permitted to go on in such a course, and that he should feel even
here the consequences of those acts."

"Yes; but my dear friend," replied Sir Arthur Adelon, "those papers
are of much importance, let me tell you. Both your character and
mine are compromised if they should ever see the light----"

"But you told me they were burned," said Mr. Filmer, with a
countenance less firm and tranquil than usual.

"Yes; so Sherborne assured me most solemnly," replied Sir Arthur


Adelon; "but nevertheless it is not the truth. They are all in the
hands of this Norries, and he is using every possible means to
render them available for his own purposes."

This was, as the reader knows, substantially true; for Sir Arthur
Adelon was one of those men who do not like to tell a direct
falsehood, even when it is their intention to deceive; and he
intended his words to convey to the mind of the priest a very
different impression of Norries' intentions, while he could always fall
back upon the precise terms he had employed, and put a larger
interpretation upon them than Mr. Filmer was likely to do at the
moment.

The priest mused. "Why what can he do with them?" he


demanded, at length, still in a thoughtful tone. "They can be of little
service to him. The time is long past; the circumstances altogether
forgotten. Charles Dudley, of St. Austin's, is dead----"

"But his son is living," replied the baronet, quickly, impatient that
his companion did not see the importance of the documents at once-
-"his son is living; Norries knows that he is here, and he threatens to
place the whole of the papers in his hands."

"That might be unpleasant, certainly," answered Filmer; "although


you had every right to act as you did act, at least such I humbly
judge to be the case; yet one would not like to have all one's private
and confidential communications to a solicitor exposed to the eyes of
an adversary's son."

"Like!" exclaimed Sir Arthur, vehemently; "Filmer, you use


wonderfully cold terms to-night! Why, it would be ruin and
destruction! Call to mind, I beg of you, all the particulars of the
transaction. Remember what was done to lead him on from expense
to expense in that business. Remember all which that man
Sherborne suggested, and which we executed. The matter of the
petition, too, against his return, and what was arranged between our
people and his own agents, and the business of the flaw in the title.
You must have forgotten, I think."

"Oh! no," replied the priest; "I have not forgotten, Sir Arthur, and
I say it would be unpleasant, very unpleasant. What does this
person Norries ask for the papers?"

"Oh! a great deal," answered Sir Arthur Adelon, still speaking with
that sort of mental reservation which he had learned betimes; "more
than I am inclined to grant: a great deal more; but I shall see him
to-night. I have an appointment with him at Barhampton, and shall
there learn what is the real extent of his demand."

The priest meditated for several minutes with a grave and


somewhat anxious countenance. "Norries," he said, at length, "was a
wild and somewhat eccentric man, but as far as I could judge, a just
and honest one. His views, too, though somewhat extreme, as his
acts were occasionally ill-timed, were all in a right direction. I am
afraid, Sir Arthur, we have fallen back from the ground we then
occupied. The truth is, my excellent friend, the Church of Rome, as it
is called, the Catholic Church, as it really is, has not that tendency
which men suppose towards the aristocratic distinctions which have
risen up in this land. It might place upon its banner the words 'Civil
liberty, spiritual submission.' It reverences all ancient things:
amongst the rest, ancient blood; but is certainly opposed to an
aristocracy springing from the people, and founded upon wealth;
although in itself it may be termed a spiritual republic, in which
every man, according to his genius and ability, can, with the grace of
God, rise to the very highest of its grades, even to the chair of St.
Peter itself. We have often seen it. But, as is the case in all republics,
the utmost submission is required to the ruling power, although
there is always a corrective for the misuse of power in the synods
and councils. It is a hierarchy, indeed, but a hierarchy open to all
men; and as a hierarchy it is opposed to the domination of all lay
powers, which are ever inclined to resist the milder influence of
spiritual powers."

"But what has all this to do with the question?" exclaimed Sir
Arthur Adelon, not comprehending what the reader has perhaps
perceived, that the priest was carrying on in words one train of
reasoning, very loosely connected with the immediate subject, while
in thought he was revolving more pertinently all the difficult points
that were before him.

"What I mean to say is this," replied Mr. Filmer. "Men consider it


strange that Roman Catholics should, from time to time, give their
support to movements savouring of republicanism; and that persons
whose views tend to republicanism should often link themselves
closely with Catholics; but as I have shown, the connexion is not at
all unnatural, and the views of this good man Norries might well be,
as they were, supported by ourselves; even were it not perfectly
right and justifiable, in the pursuit of a great and all-important
object, to combine even with men the most opposed to us in the
minor points of politics, when by so doing we see the probability of
advancing the truth."

"What! would you have me, then, join with him now?" exclaimed
Sir Arthur, in considerable surprise; for the arguments of Father
Peter went so directly to support the inducements held out by
Norries, that the baronet could hardly persuade himself there had
not been some communication between the Chartist and the priest.

"I did not exactly say that," answered Filmer. "Men's views
frequently undergo a change in a few years. I know not what this
man's opinions may now be. He was then an eager advocate for
perfect freedom of religious opinions; he was then for sweeping
away altogether what they call here the Church of the State, and
leaving every man to follow what creed he thinks best."

"But, surely, my reverend friend," exclaimed Sir Arthur Adelon,


"such are principles you would never support or even tolerate? It
was in his religious views alone that I differed from Norries."

The priest smiled with one of those calm, sagacious smiles that
have a certain though moderate portion of triumph in them, the
triumph of superior astuteness. "I would support them for their
hour," he said. "I remember hearing of a wise stratagem practised
by a great general who was besieging a refractory city. The
inhabitants had dammed up a river which ran on one side of the
town, and thus had defended their walls on that side from all attack.
The dam or barrier which they had constructed was immediately
under the fire of one of their strongest works, so that it was
unassailable; but the general of whom I speak, by a week's hard
labour, turned the course of a still larger river into that which served
for their defence, and the mighty torrent, rushing down, swept away
the barriers altogether. The river resumed its equal flow, and the
attacking army, marching on, took the town by storm on the very
side where it had been judged impregnable. Now, my dear friend,
the Catholic religion is the attacking army; the revolted and besieged
city is this country of England; the overflowed river which defends us
is moderate toleration of opinion; the barrier which keeps the waters
up is the heretical church of this country, and we have nought to do
but to pour the torrent of licentious freedom against that barrier till
it is quite overthrown, in order to have a clear way for our march,
and to secure our ultimate triumph."

The baronet paused and mused for several moments, partly


considering the new views which his companion had propounded,
partly debating with himself as to whether he should make his
confidence more complete than he had at first intended, and before
he replied Mr. Filmer went on again. "I do not mean to say, Sir
Arthur," he continued, "that I would advise you to take any rash or
dangerous step; and indeed, on the contrary, I think you had a great
deal better, while you give encouragement to the moral movement,
oppose most strongly all appeal to force, till the country is far more
prepared for it than at present. To show yourself upon their side may
give vigour to their proceedings, may gain many adherents to range
themselves openly with them who are merely restrained by fear and
timidity, and may assist them in raising that prestige of power,
numbers, and respectability, which, if it can be maintained, conquers
in the end all opposition; for as you are well aware, so curiously
constituted is the mind of this nation, that no question, however
absurd, no view, however false, no measure, however evil and
detrimental, will not gain the adherence of the great multitude if
they can once be taught to believe, by truth or falsehood, that it is
supported by numbers and by respectability. I have no doubt that, if
I could show, or rather, if I could persuade, the people of England
that there are a million or two of atheists in the land demanding the
abolition of all religious worship whatsoever, the great body of the
people would be easily induced to renounce their God, and
endeavour to sweep away every trace of religion from the land.
There is no being on the face of the earth so susceptible of moral
contagion as an Englishman."

"It is a dark view of the case," said Sir Arthur Adelon.

"But a true one," answered Filmer; "otherwise England would


have been still Catholic. However, to return to these papers. You say
you will see Norries again tonight; you must then discover what is
the extent of his demand. I would make him no promises, were I in
your place, till I had had time for thought and deliberation; neither
would I refuse anything that he might demand, that is to say, not
absolutely, till we have consulted together. I will go with you, if you
like, to speak with him."

"I do not think he would open his views before another," said Sir
Arthur, hastily; "but as it is well, my reverend friend, to be prepared
against the worst, let us consider what must be done should this
man's views be very exorbitant, and should he refuse all time for
deliberation."

"Then you must say 'No,' of course," replied Filmer; "and we will
take measures against his measures."

"I see none that we can take," answered the baronet, gloomily.
"He would instantly place the papers in this young man's hands, and
then ruin, and destruction, and disgrace, would be the
consequence."

"Should you find that there is danger of his doing so suddenly,"


was Mr. Filmer's reply, "we must deal with Mr. Dudley ourselves,
either in attaching him to us by bringing him over to the true faith
again, or----"
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like