100% found this document useful (2 votes)
37 views65 pages

Interactive Web-Based Data Visualization With R, Plotly, and Shiny 1st Edition Carson Sievert 2024 Scribd Download

Interactive

Uploaded by

bloorlapkaks
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 (2 votes)
37 views65 pages

Interactive Web-Based Data Visualization With R, Plotly, and Shiny 1st Edition Carson Sievert 2024 Scribd Download

Interactive

Uploaded by

bloorlapkaks
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/ 65

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Interactive Web-Based Data Visualization with R,


Plotly, and Shiny 1st Edition Carson Sievert

https://textbookfull.com/product/interactive-web-based-data-
visualization-with-r-plotly-and-shiny-1st-edition-carson-
sievert/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/

textboxfull.com

Interactive Data Visualization for the Web Murray

https://textbookfull.com/product/interactive-data-visualization-for-
the-web-murray/

textboxfull.com

Interactive Data Visualization for the Web An Introduction


to Designing with D3 1st Edition Murray

https://textbookfull.com/product/interactive-data-visualization-for-
the-web-an-introduction-to-designing-with-d3-1st-edition-murray/

textboxfull.com

Interactive Data Visualization for the Web An Introduction


to Designing with D3 2nd Edition Scott Murray

https://textbookfull.com/product/interactive-data-visualization-for-
the-web-an-introduction-to-designing-with-d3-2nd-edition-scott-murray/

textboxfull.com
ggplot2 Elegant Graphics For Data Analysis Second Edition
Hadley Wickham Carson Sievert

https://textbookfull.com/product/ggplot2-elegant-graphics-for-data-
analysis-second-edition-hadley-wickham-carson-sievert/

textboxfull.com

Modern Data Visualization with R (Chapman & Hall/CRC The R


Series) 1st Edition Kabacoff

https://textbookfull.com/product/modern-data-visualization-with-r-
chapman-hall-crc-the-r-series-1st-edition-kabacoff/

textboxfull.com

Learning IPython for Interactive Computing and Data


Visualization - Second Edition Cyrille Rossant

https://textbookfull.com/product/learning-ipython-for-interactive-
computing-and-data-visualization-second-edition-cyrille-rossant/

textboxfull.com

Building Responsive Data Visualization for the Web 1st


Edition Hinderman

https://textbookfull.com/product/building-responsive-data-
visualization-for-the-web-1st-edition-hinderman/

textboxfull.com

Data Visualization Representing Information on Modern Web


1st Edition Kirk

https://textbookfull.com/product/data-visualization-representing-
information-on-modern-web-1st-edition-kirk/

textboxfull.com
Interactive Web-Based
Data Visualization with
R, plotly, and shiny
Chapman & Hall/CRC
The R Series
Series Editors
John M. Chambers, Department of Statistics, Stanford University, California, USA
Torsten Hothorn, Division of Biostatistics, University of Zurich, Switzerland
Duncan Temple Lang, Department of Statistics, University of California, Davis, USA
Hadley Wickham, RStudio, Boston, Massachusetts, USA

Recently Published Titles

Analyzing Baseball Data with R, Second Edition


Max Marchi, Jim Albert, Benjamin S. Baumer

Spatio-Temporal Statistics with R


Christopher K. Wikle, Andrew Zammit-Mangion, and Noel Cressie

Statistical Computing with R, Second Edition


Maria L. Rizzo

Geocomputation with R
Robin Lovelace, Jakub Nowosad, Jannes Muenchow

Advanced R, Second Edition


Hadley Wickham

Dose Response Analysis Using R


Christian Ritz, Signe Marie Jensen, Daniel Gerhard, Jens Carl Streibig

Distributions for Modelling Location, Scale, and Shape


Using GAMLSS in R
Robert A. Rigby , Mikis D. Stasinopoulos, Gillian Z. Heller and Fernanda De Bastiani

Hands-On Machine Learning with R


Bradley Boehmke and Brandon Greenwell

Statistical Inference via Data Science


A ModernDive into R and the Tidyverse
Chester Ismay and Albert Y. Kim

Reproducible Research with R and RStudio, Third Edition


Christopher Gandrud

Interactive Web-Based Data Visualization with R, plotly, and shiny


Carson Sievert

For more information about this series, please visit: https://www.crcpress.com/


Chapman--HallCRC-The-R-Series/book-series/CRCTHERSER
Interactive Web-Based
Data Visualization with
R, plotly, and shiny

Carson Sievert
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742

© 2020 by Taylor & Francis Group, LLC


CRC Press is an imprint of Taylor & Francis Group, an Informa business

No claim to original U.S. Government works

Printed on acid-free paper

International Standard Book Number-13: 978-1-138-33145-7 (Paperback)


International Standard Book Number-13: 978-1-138-33149-5 (Hardback)

This book contains information obtained from authentic and highly regarded sources. Reasonable
efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and
publishers have attempted to trace the copyright holders of all material reproduced in this publication
and apologize to copyright holders if permission to publish in this form has not been obtained. If any
copyright material has not been acknowledged please write and let us know so we may rectify in any
future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information
storage or retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, please access
www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc.
(CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization
that provides licenses and registration for a variety of users. For organizations that have been granted
a photocopy license by the CCC, a separate system of payment has been arranged.

Trademark Notice: Product or corporate names may be trademarks or registered trademarks and
are used only for identification and explanation without intent to infringe.

Visit the Taylor & Francis Web site at


http://www.taylorandfrancis.com

and the CRC Press Web site at


http://www.crcpress.com
For the R community: Your kindness and generosity are truly
inspiring.
Contents

1 Introduction 1
1.1 Why interactive web graphics from R? . . . . . . . . . 1
1.2 What you will learn . . . . . . . . . . . . . . . . . . 7
1.3 What you won’t learn (much of) . . . . . . . . . . . . 12
1.3.1 Web technologies . . . . . . . . . . . . . . . 12
1.3.2 d3js . . . . . . . . . . . . . . . . . . . . . . . 12
1.3.3 ggplot2 . . . . . . . . . . . . . . . . . . . . . 12
1.3.4 Graphical data analysis . . . . . . . . . . . . 13
1.3.5 Data visualization best practices . . . . . . . 13
1.4 Prerequisites . . . . . . . . . . . . . . . . . . . . . . 13
1.5 Run code examples . . . . . . . . . . . . . . . . . . . 14
1.6 Getting help and learning more . . . . . . . . . . . . 14
1.7 Acknowledgments . . . . . . . . . . . . . . . . . . . 15
1.8 Colophon . . . . . . . . . . . . . . . . . . . . . . . . 16

I Creating views 21
2 Overview 23
2.1 Intro to plot_ly() . . . . . . . . . . . . . . . . . . . . 23
2.2 Intro to plotly.js . . . . . . . . . . . . . . . . . . . . 32
2.3 Intro to ggplotly() . . . . . . . . . . . . . . . . . . . 36

3 Scattered foundations 45
3.1 Markers . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.1.1 Alpha blending . . . . . . . . . . . . . . . . . 52
3.1.2 Colors . . . . . . . . . . . . . . . . . . . . . . 53
3.1.3 Symbols . . . . . . . . . . . . . . . . . . . . . 56
3.1.4 Stroke and span . . . . . . . . . . . . . . . . 59
3.1.5 Size . . . . . . . . . . . . . . . . . . . . . . . 60
3.1.6 Dotplots and error bars . . . . . . . . . . . . 62

vii
viii Contents

3.2 Lines . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.2.1 Linetypes . . . . . . . . . . . . . . . . . . . . 64
3.2.2 Segments . . . . . . . . . . . . . . . . . . . . 66
3.2.3 Density plots . . . . . . . . . . . . . . . . . . 73
3.2.4 Parallel coordinates . . . . . . . . . . . . . . 74
3.3 Polygons . . . . . . . . . . . . . . . . . . . . . . . . 77
3.3.1 Ribbons . . . . . . . . . . . . . . . . . . . . . 79

4 Maps 81
4.1 Integrated maps . . . . . . . . . . . . . . . . . . . . 82
4.1.1 Overview . . . . . . . . . . . . . . . . . . . . 82
4.1.2 Choropleths . . . . . . . . . . . . . . . . . . 91
4.2 Custom maps . . . . . . . . . . . . . . . . . . . . . . 94
4.2.1 Simple features (sf) . . . . . . . . . . . . . . 94
4.2.2 Cartograms . . . . . . . . . . . . . . . . . . . 101

5 Bars and histograms 107


5.1 Multiple numeric distributions . . . . . . . . . . . . 110
5.2 Multiple discrete distributions . . . . . . . . . . . . 111

6 Boxplots 115

7 2D frequencies 119
7.1 Rectangular binning in plotly.js . . . . . . . . . . . . 119
7.2 Rectangular binning in R . . . . . . . . . . . . . . . 120
7.3 Categorical axes . . . . . . . . . . . . . . . . . . . . 122

8 3D charts 125
8.1 Markers . . . . . . . . . . . . . . . . . . . . . . . . . 125
8.2 Paths . . . . . . . . . . . . . . . . . . . . . . . . . . 126
8.3 Lines . . . . . . . . . . . . . . . . . . . . . . . . . . 127
8.4 Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
8.5 Surfaces . . . . . . . . . . . . . . . . . . . . . . . . 130

II Publishing views 133


9 Introduction 135

10 Saving and embedding HTML 137


Contents ix

11 Exporting static images 141


11.1 With code . . . . . . . . . . . . . . . . . . . . . . . . 141
11.2 From a browser . . . . . . . . . . . . . . . . . . . . 142
11.3 Sizing exports . . . . . . . . . . . . . . . . . . . . . 144

12 Editing views for publishing 145

III Combining multiple views 149


13 Arranging views 151
13.1 Arranging plotly objects . . . . . . . . . . . . . . . . 151
13.1.1 Recursive subplots . . . . . . . . . . . . . . . 155
13.1.2 Other approaches and applications . . . . . . 158
13.2 Arranging htmlwidgets . . . . . . . . . . . . . . . . 164
13.2.1 flexdashboard . . . . . . . . . . . . . . . . . 165
13.2.2 Bootstrap grid layout . . . . . . . . . . . . . 166
13.2.3 CSS flexbox . . . . . . . . . . . . . . . . . . . 167
13.3 Arranging many views . . . . . . . . . . . . . . . . . 169

14 Animating views 173


14.1 Animation API . . . . . . . . . . . . . . . . . . . . . 173
14.2 Animation support . . . . . . . . . . . . . . . . . . . 177

IV Linking multiple views 183


15 Introduction 185

16 Client-side linking 189


16.1 Graphical queries . . . . . . . . . . . . . . . . . . . 189
16.2 Highlight versus filter events . . . . . . . . . . . . . 198
16.3 Linking animated views . . . . . . . . . . . . . . . . 204
16.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . 208
16.4.1 Querying faceted charts . . . . . . . . . . . . 208
16.4.2 Statistical queries . . . . . . . . . . . . . . . 214
16.4.3 Statistical queries with ggplotly() . . . . . . . 219
16.4.4 Geo-spatial queries . . . . . . . . . . . . . . . 222
16.4.5 Linking with other htmlwidgets . . . . . . . . 226
x Contents

16.4.6 Generalized pairs plots . . . . . . . . . . . . 229


16.4.7 Querying diagnostic plots . . . . . . . . . . . 230
16.5 Limitations . . . . . . . . . . . . . . . . . . . . . . . 236

17 Server-side linking with shiny 239


17.1 Embedding plotly in shiny . . . . . . . . . . . . . . . 240
17.1.1 Your first shiny app . . . . . . . . . . . . . . 240
17.1.2 Hiding and redrawing on resize . . . . . . . . 244
17.2 Leveraging plotly input events . . . . . . . . . . . . 246
17.2.1 Dragging events . . . . . . . . . . . . . . . . 247
17.2.2 3D events . . . . . . . . . . . . . . . . . . . . 249
17.2.3 Edit events . . . . . . . . . . . . . . . . . . . 251
17.2.4 Relayout vs. restyle events . . . . . . . . . . . 256
17.2.5 Scoping events . . . . . . . . . . . . . . . . . 259
17.2.6 Event priority . . . . . . . . . . . . . . . . . 262
17.2.7 Handling discrete axes . . . . . . . . . . . . . 264
17.2.8 Accumulating and managing event data . . . 267
17.3 Improving performance . . . . . . . . . . . . . . . . 270
17.3.1 Partial plotly updates . . . . . . . . . . . . . 271
17.3.2 Partial update examples . . . . . . . . . . . . 276
17.4 Advanced applications . . . . . . . . . . . . . . . . . 282
17.4.1 Drill-down . . . . . . . . . . . . . . . . . . . 282
17.4.2 Cross-filter . . . . . . . . . . . . . . . . . . . 298
17.4.3 A draggable brush . . . . . . . . . . . . . . . 307
17.5 Discussion . . . . . . . . . . . . . . . . . . . . . . . 308

V Event handling in JavaScript 311


18 Introduction 313

19 Working with JSON 319


19.1 Assignment, subsetting, and iteration . . . . . . . . 319
19.2 Mapping R to JSON . . . . . . . . . . . . . . . . . . 322

20 Adding custom event handlers 325

21 Supplying custom data 327


Contents xi

22 Leveraging web technologies from R 343


22.1 Web infrastructure . . . . . . . . . . . . . . . . . . 343
22.2 Modern JS and React . . . . . . . . . . . . . . . . . . 345

VI Various special topics 353


23 Is plotly free and secure? 355

24 Improving performance 357

25 Controlling tooltips 359


25.1 plot_ly() tooltips . . . . . . . . . . . . . . . . . . . . 359
25.2 ggplotly() tooltips . . . . . . . . . . . . . . . . . . . 365
25.3 Styling . . . . . . . . . . . . . . . . . . . . . . . . . 370

26 Control the modebar 373


26.1 Remove the entire modebar . . . . . . . . . . . . . . 373
26.2 Remove the plotly logo . . . . . . . . . . . . . . . . . 373
26.3 Remove modebar buttons by name . . . . . . . . . . 374
26.4 Add custom modebar buttons . . . . . . . . . . . . . 374
26.5 Control image downloads . . . . . . . . . . . . . . . 376

27 Working with colors 379

28 Working with symbols and glyphs 383

29 Embedding images 387

30 Language support 391

31 LaTeX rendering 397


31.1 MathJax caveats . . . . . . . . . . . . . . . . . . . . 400

32 The data-plot-pipeline 401

33 Improving ggplotly() 407


33.1 Modifying layout . . . . . . . . . . . . . . . . . . . . 408
33.2 Modifying data . . . . . . . . . . . . . . . . . . . . . 409
33.3 Leveraging statistical output . . . . . . . . . . . . . 412
xii Contents

34 Translating custom ggplot2 geoms 417

Bibliography 421

Index 433
1
Introduction

1.1 Why interactive web graphics from R?


As Wickham and Grolemund (2016) argue, the exploratory phase of a
data science workflow (Figure 1.1) requires lots of iteration between
data manipulation, visualization, and modeling. Achieving these tasks
through a programming language like R offers the opportunity to scale
and automate tasks, document and track them, and reliably reproduce
their output. That power, however, typically comes at the cost of in
creasing the amount of cognitive load involved relative to a GUI-based
system.1 R packages like the tidyverse have been incredibly successful
due to their ability to limit cognitive load without removing the bene
fits of performing analysis via code. Moreover, the tidyverse’s unifying
principles of designing for humans, consistency, and composability
make iteration within and between these stages seamless – an impor
tant but often overlooked challenge in exploratory data analysis (EDA)
(Tidyverse team, 2018).
1
For more on the benefits of using code over a GUI to perform data analysis, see
Wickham (2018b).

1
2 1 Introduction

FIGURE 1.1: The stages of a data science workflow from Wickham and
Grolemund (2016).

In fact, packages within the tidyverse such as dplyr (transformation)


and ggplot2 (visualization) are such productive tools that many ana
lysts use static ggplot2 graphics for EDA. Then, when it comes to com
municating results, some analysts switch to another tool or language
altogether (e.g., JavaScript) to generate interactive web graphics pre
senting their most important findings (Yau, 2016; Quealy, 2013). Un
fortunately, this requires a heavy context switch that requires a totally
different skillset and impedes productivity. Moreover, for the average
analyst, the opportunity costs involved with becoming competent with
the complex world of web technologies is simply not worth the required
investment.
Even before the web, interactive graphics were shown to have great
promise in aiding the exploration of high-dimensional data (Cook et al.,
2007). The ASA maintains an incredible video library, http://stat
graphics.org/movies/, documenting the use of interactive statistical
graphics for tasks that otherwise wouldn’t have been easy or possi
ble using numerical summaries and/or static graphics alone. Roughly
speaking, these tasks tend to fall under three categories:
• Identifying structure that would otherwise go missing (Tukey and
Fisherkeller, 1973).
• Diagnosing models and understanding algorithms (Wickham et al.,
2015).
1.1 Why interactive web graphics from R? 3

• Aiding the sense-making process by searching for information


quickly without fully specified questions (Unwin and Hofmann,
1999).
Today, you can find and run some of these and similar Graph
ical User Interface (GUI) systems for creating interactive graph
ics: DataDesk https://datadescription.com/, GGobi http://www.ggobi.
org/, Mondrian http://www.theusrus.de/Mondrian/, JMP https://www.jmp.
com, Tableau https://www.tableau.com/. Although these GUI-based sys
tems have nice properties, they don’t gel with a code-based workflow:
any tasks you complete through a GUI likely can’t be replicated without
human intervention. That means, if at any point, the data changes, and
analysis outputs must be regenerated, you need to remember precisely
how to reproduce the outcome, which isn’t necessarily easy, trustwor
thy, or economical. Moreover, GUI-based systems are typically ‘closed’
systems that don’t allow themselves to be easily customized, extended,
or integrated with another system.
Programming interactive graphics allows you to leverage all the ben
efits of a code-based workflow while also helping with tasks that are
difficult to accomplish with code alone. For an example, if you were
to visualize engine displacement (displ) versus miles per gallon (hwy)
using the mpg dataset, you might wonder: “what are these cars with an
unusually high value of hwy given their displ?”. Rather than trying to
write code to query those observations, it would be easier and more
intuitive to draw an outline around the points to query the data behind
them.

library(ggplot2)
ggplot(mpg, aes(displ, hwy)) + geom_point()
4 1 Introduction

FIGURE 1.2: A scatterplot of engine displacement versus miles per


gallon made with the ggplot2 package.

Figure 1.3 demonstrates how we can transform Figure 1.2 into an inter
active version that can be used to query and inspect points of interest.
The framework that enables this kind of linked brushing is discussed
in depth within Section 16.1, but the point here is that the added ef
fort required to enable such functionality is relatively small. This is
important, because although interactivity can augment exploration by
allowing us to pursue follow-up questions, it’s typically only practical
when we can create and alter them quickly. That’s because, in a true
exploratory setting, you have to make lots of visualizations, and inves
tigate lots of follow-up questions, before stumbling across something
truly valuable.

library(plotly)
m <- highlight_key(mpg)
p <- ggplot(m, aes(displ, hwy)) + geom_point()
gg <- highlight(ggplotly(p), "plotly_selected")
crosstalk::bscols(gg, DT::datatable(m))
1.1 Why interactive web graphics from R? 5

FIGURE 1.3: Linked brushing in a scatterplot to query more informa


tion about points of interest. By lasso selecting a region of unusual
points, we learn that the corvette model has unusually high miles
per gallon considering the engine size. For a video demonstration of
the interactive, see https://bit.ly/mpg-lasso. For the interactive, see
https://plotly-r.com/interactives/mpg-lasso.html

When a valuable insight surfaces, since the code behind Figure 1.3
generates HTML, the web-based graphic can be easily shared with
collaborators through email and/or incorporated inside a larger auto
mated report or website. Moreover, since these interactive graphics
are based on the htmlwidgets framework, they work seamlessly in
side larger rmarkdown documents, inside shiny apps, RStudio, Jupyter
notebooks, the R prompt, and more. Being able to share interactive
graphics with collaborators through these different mediums enhances
the conversation – your colleagues can point out things you may not yet
have considered and, in some cases, they can get immediate responses
from the graphics themselves.
In the final stages of an analysis, when it comes time to publish your
work to a general audience, rather than relying on the audience to
interact with the graphics and discover insight for themselves, it’s
always a good idea to clearly highlight your findings. For example,
from Figure 1.3, we’ve learned that most of these unusual points can
be explained by a single feature of the data (model == 'corvette'). As
shown in Figure 1.4, the geom_mark_hull() function from the ggforce
package provides a helpful way to annotate those points with a hull.
Moreover, as Chapter 12 demonstrates, it can also be helpful to add
6 1 Introduction

and/or edit annotations interactively when preparing a graphic for


publication.

library(ggforce)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
geom_mark_hull(aes(filter = model == "corvette", label = model)) +
labs(
title = "Fuel economy from 1999 to 2008 for 38 car models",
caption = "Source: https://fueleconomy.gov/",
x = "Engine Displacement",
y = "Miles Per Gallon"
)

FIGURE 1.4: Using the ggforce package to annotate the corvettes in


this dataset.

This simple example quickly shows how interactive web graphics can
assist EDA (for another, slightly more in-depth example, see Section
2.3). Being able to program these graphics from R allows one to combine
1.2 What you will learn 7

their functionality within a world-class computing environment for


data analysis and statistics. Programming interactive graphics may
not be as intuitive as using a GUI-based system, but making the invest
ment pays dividends in terms of workflow improvements: automation,
scaling, provenance, and flexibility.

1.2 What you will learn


This book provides a foundation for learning how to make interactive
web-based graphics for data analysis from R via plotly, without assum
ing any prior experience with web technologies. The goal is to provide
the context you need to go beyond copying existing plotly examples
to having a useful mental model of the underlying framework, its ca
pabilities, and how it fits into the larger R ecosystem. By learning this
mental model, you’ll have a better understanding of how to create more
sophisticated visualizations, fix common issues, improve performance,
understand the limitations, and even contribute back to the project
itself. You may already be familiar with existing plotly documentation
(e.g., https://plot.ly/r/), which is essentially a language-agnostic how
to guide, but this book is meant to be a more holistic tutorial written
by and for the R user.
This book also focuses primarily on features that are unique to the
plotly R package (i.e., things that don’t work the same for Python
or JavaScript). This ranges from creation of a single graph using the
plot_ly() special named arguments that make it easier to map data to
visuals, as shown in Figure 1.5 (see more in Section 2.1). To its ability
to link multiple data views purely client-side, as shown in Figure 1.6
(see more in Section 16.1). To advanced server-side linking with shiny
to implement responsive and scalable crossfilters, as shown in Figure
1.7 (see more in Section 17.4.2).

plot_ly(diamonds, x = ~cut, color = ~clarity, colors = "Accent")


8 1 Introduction

FIGURE 1.5: An example of what you’ll learn: Figure 2.7. For a


video demonstration of the interactive, see https://bit.ly/intro-show
hide. For the interactive, see https://plotly-r.com/interactives/intro
show-hide.html

FIGURE 1.6: An example of what you’ll learn: Figure 16.21. For a video
demonstration of the interactive, see https://bit.ly/storms-preview.
For the interactive, see https://plotly-r.com/interactives/storms.html
1.2 What you will learn 9

FIGURE 1.7: An example of what you’ll learn: Figure


17.28. For a video demonstration of the interactive, see
https://bit.ly/shiny-crossfilter. For the interactive, see
https://plotly-r.com/interactives/shiny-crossfilter.html

By going through the code behind these examples, you’ll see that many
of them leverage other R packages in their implementation. To highlight
a few of the R packages that you’ll see:
• dplyr and tidyr
– For transforming data into a form suitable for the visualiza
tion method.
• ggplot2 and friends (e.g., GGally, ggmosaic, etc.)
– For creating plotly visualizations that would be tedious to
implement without ggplotly().
• sf, rnaturalearth, cartogram
– For obtaining and working with geo-spatial data structures
in R.
• stats, MASS, broom, and forecast
– For working with statistical models and summaries.
• shiny
– For running R code in response to user input.
• htmltools, htmlwidgets
– For combining multiple views and saving the result.
This book contains six parts and each part contains numerous chapters.
A summary of each part is provided below.
10 1 Introduction

1. Creating views: introduces the process of transforming data


into graphics via plotly’s programmatic interface. It focuses
mostly on plot_ly(), which can interface directly with the
underlying plotly.js graphing library, but emphasis is put on
features unique to the R package that make it easier to trans
form data into graphics. Another way to create graphs with
plotly is to use the ggplotly() function to transform ggplot2
graphs into plotly graphs. Section 2.3 discusses when and
why ggplotly() might be desirable to plot_ly(). It’s also worth
mentioning that this part (nor the book as a whole) does not
intend to cover every possible chart type and option available
in plotly – it’s more of a presentation of the most generally
useful techniques with the greater R ecosystem in mind. For
a more exhaustive gallery of examples of what plotly itself is
capable of, see https://plot.ly/r/.
2. Publishing views: discusses various techniques for exporting
(as well as embedding) plotly graphs to various file formats
(e.g., HTML, SVG, PDF, PNG, etc.). Also, Chapter 12 demon
strates how one could leverage editable layout components
HTML to touch up a graph, then export to a static file format
of interest before publication. Indeed, this book was created
using the techniques from this section.
3. Combining multiple views: demonstrates how to combine mul
tiple data views into a single webpage (arranging) or graphic
(animation). Most of these techniques are shown using plotly
graphs, but techniques from Section 13.2 extend to any HTML
content generated via htmltools (which includes htmlwid
gets).
4. Linking multiple views: provides an overview of the two mod
els for linking plotly graph(s) to other data views. The first
model, covered in Section 16.1, outlines plotly’s support for
linking views purely client-side, meaning the resulting graphs
render in any web browser on any machine without requir
ing external software. The second model, covered in Chap
ter 17, demonstrates how to link plotly with other views
via shiny, a reactive web application framework for R. Rel
1.3 What you will learn 11

atively speaking, the second model grants the R user way


more power and flexibility, but comes at the cost of requiring
more computational infrastructure. That being said, RStu
dio provides accessible resources for deploying shiny apps
https://shiny.rstudio.com/articles/#deployment.

5. Custom behavior with JavaScript: demonstrates various ways


to customize plotly graphs by writing custom JavaScript to
handle certain user events. This part of the book is designed
to be approachable for R users that want to learn just enough
JavaScript to plotly to do something it doesn’t “natively” sup
port.
6. Various special topics: offers a grab-bag of topics that address
common questions, mostly related to the customization of
plotly graphs in R.

You might already notice that this book often uses the term ‘view’ or
‘data view’, so here we take a moment to frame its use in a wider con
text. As Wills (2008) puts it: “a ‘data view’ is anything that gives the
user a way of examining data so as to gain insight and understanding.
A data view is usually thought of as a barchart, scatterplot, or other
traditional statistical graphic, but we use the term more generally, in
cluding ‘views’ such as the results of a regression analysis, a neural net
prediction, or a set of descriptive statistics”. In this book, more often
than not, the term ‘view’ typically refers to a plotly graph or other html
widgets (e.g., DT, leaflet, etc.). In particular, Section 16.1 is all about
linking multiple htmlwidgets together through a graphical database
querying framework. However, the term ‘view’ takes on a more general
interpretation in Chapter 17 since the reactive programming frame
work that shiny provides allows us to have a more general conversation
surrounding linked data views.
12 1 Introduction

1.3 What you won’t learn (much of)


1.3.1 Web technologies
Although this book is fundamentally about creating web graphics, it
does not aim to teach you web technologies (e.g., HTML, SVG, CSS,
JavaScript, etc.). It’s true that mastering these technologies grants you
the ability to build really impressive websites, but even expert web
developers would say their skillset is much better suited for exposi
tory rather than exploratory visualization. That’s because, most web
programming tools are not well-suited for the exploratory phase of
a data science workflow where iteration between data visualization,
transformation, and modeling is a necessary task that often impedes
hypothesis generation and sense-making. As a result, for most data
analysts whose primary function is to derive insight from data, the
opportunity costs involved with mastering web technologies is usually
not worth the investment.
That being said, learning a little about web technologies can have a rela
tively large payoff with directed learning and instruction. In Chapter 18,
you’ll learn how to customize plotly graphs with JavaScript – even if you
haven’t seen JavaScript before, this chapter should be approachable,
insightful, and provide you with some useful examples.

1.3.2 d3js
The JavaScript library D3 is a great tool for data visualization assuming
you’re familiar with web technologies and are primarily interested
in expository (not exploratory) visualization. There are already lots
of great resources for learning D3, including the numerous books by
Murray (2013) and Murray (2017). It’s worth noting, however, if you do
know D3, you can easily leverage it from a webpage that is already a
plotly graph, as demonstrated in Figure 22.1.

1.3.3 ggplot2
The book does contain some ggplot2 code examples (which are then
converted to plotly via ggplotly()), but it’s not designed to teach you
1.5 Prerequisites 13

ggplot2. For those looking to learn ggplot2, I recommend using the


learning materials listed at https://ggplot2.tidyverse.org.

1.3.4 Graphical data analysis


How to perform data analysis via graphics (carefully, correctly, and cre
atively) is a large topic in itself. Although this book does have examples
of graphical data analysis, it does not aim to provide a comprehensive
foundation. For nice comprehensive resources on the topic, see Unwin
(2015) and Cook and Swayne (2007).

1.3.5 Data visualization best practices


Encoding information in a graphic (concisely and effectively) is a large
topic unto itself. Although this book does have some ramblings related
to best practices in data visualization, it does not aim to provide a
comprehensive foundation. For some approachable and fun resources
on the topic, see Tufte (2001), Yau (2011), Healey (2018), and Wilke
(2018).

1.4 Prerequisites
For those new to R and/or data visualization, R for Data Science2 pro
vides an excellent foundation for understanding the vast majority of
concepts covered in this book (Wickham and Grolemund, 2016). In
particular, if you have a solid grasp on Part I: Explore3 , Part II: Wran
gle4 , and Part III: Program5 , you should be able to understand almost
everything here. Although not explicitly covered, the book does make
references to (and was creating using) rmarkdown, so if you’re new to
rmarkdown, I also recommend reading the R Markdown chapter6 .
2
https://r4ds.had.co.nz/
3
https://r4ds.had.co.nz/explore-intro.html
4
https://r4ds.had.co.nz/wrangle-intro.html
5
https://r4ds.had.co.nz/program-intro.html
6
https://r4ds.had.co.nz/r-markdown.html
14 1 Introduction

1.5 Run code examples


This book contains many code examples in an effort to teach the art and
science behind creating interactive web-based graphics using plotly.
To interact with the code results, you may either: (1) click on the static
graphs hosted online at https://plotly-r.com and/or execute the code
in a suitable computational environment. Most code examples assume
you already have the plotly package loaded:

library(plotly)

If a particular code chunk doesn’t work, you may need to load packages
from previous examples in the chapter (some examples assume you’re
following the chapter in a linear fashion).
If you’d like to run examples on your local machine (instead of RStudio
Cloud), you can install all the necessary R packages with:

if (!require(remotes)) install.packages("remotes")
remotes::install_github("cpsievert/plotly_book")

Visit http://bit.ly/plotly-book-cloud for a cloud-based instance of


RStudio with all the required software to run the code examples in
this book.

1.6 Getting help and learning more


As Wickham and Grolemund (2016) states, “This book is not an island;
there is no single resource that will allow you to master R [or plotly]. As
you start to apply the techniques described in this book to your own
data, you will soon find questions that I do not answer. This section
describes a few tips on how to get help, and to help you keep learning.”
1.7 Acknowledgments 15

These tips7 on how to get help (e.g., Google, StackOverflow, Twitter,


etc.) also apply to getting help with plotly. RStudio’s community8 is an
other great place to ask broader questions about all things R and plotly.
It’s worth mentioning that the R community is incredibly welcoming,
compassionate, and generous; especially if you can demonstrate that
you’ve done your research and/or provide a minimally reproducible
example of your problem9 .

1.7 Acknowledgments
This book wouldn’t be possible without the generous assistance and
mentorship of many people:
• Heike Hofmann and Di Cook for their mentorship and many helpful
conversations about interactive graphics.
• Toby Dylan Hocking for many helpful conversations, his mentor-
ship in the R packages animint and plotly, and laying the original
foundation behind ggplotly().
• Joe Cheng for many helpful conversations and inspiring Section 16.1.
• Étienne Tétreault-Pinard, Alex Johnson, and the other plotly.js core
developers for responding to my feature requests and bug reports.
• Yihui Xie for his work on knitr, rmarkdown, bookdown, bookdown
crc10 , and responding to my feature requests.
• Anthony Unwin for helpful feedback, suggestions, and for inspiring
Figure 16.13.
• Hadley Wickham and the ggplot2 team for maintaining ggplot2.
• Hadley Wickham and Garret Grolemund for writing R for Data Science
and allowing me to model this introduction after their introduction.
• Kent Russell for contributions to plotly, htmlwidgets, and reactR.
• Adam Loy for inspiring Figure 14.5.
7
https://r4ds.had.co.nz/introduction.html#getting-help-and-learning-more
8
https://community.rstudio.com/tags/plotly
9
https://www.tidyverse.org/help/
10
https://github.com/yihui/bookdown-crc
16 1 Introduction

• Many other R community members who contributed to the plotly


package and provided feedback and corrections for this book.

1.8 Colophon
An online version of this book is available at https://plotly-r.com. It
will continue to evolve in between reprints of the physical book. The
source of the book is available at https://github.com/cpsievert/plotly_
book. The book is powered by https://bookdown.org which makes it easy
to turn R markdown files into HTML, PDF, and EPUB.
This book was built with the following computing environment:

devtools::session_info("plotly")
#> - Session info -------------------------------------
#> setting value
#> version R version 3.6.1 (2019-07-05)
#> os macOS Mojave 10.14.5
#> system x86_64, darwin15.6.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/Chicago
#> date 2019-10-07
#>
#> - Packages -----------------------------------------
#> package * version date lib
#> askpass 1.1 2019-01-13 [1]
#> assertthat 0.2.1 2019-03-21 [1]
#> backports 1.1.5 2019-10-02 [1]
#> base64enc 0.1-3 2015-07-28 [1]
#> BH 1.69.0-1 2019-01-07 [1]
#> cli 1.1.0 2019-03-19 [1]
#> colorspace 1.4-1 2019-03-18 [1]
Other documents randomly have
different content
Le vieux ronflait dans la salle basse.
Il ne se douterait de rien.
D’ailleurs, mon amour-propre ne me permettait plus de reculer.
Bravement, je détachai ma ceinture de corde, je l’enroulai autour
de mon poignet pour me conserver un point d’appui en cas de
vertige, et je me courbai vers la fenêtre, mon front juste à la
hauteur de la vitre.
Alors, je lâchai la corde et je poussai un cri.
J’avais vu, oui, j’avais bien vu… derrière l’étroit miroir de verre,
une autre tête que la mienne qui me regardait.
Je demeurai un instant collé contre la muraille, les cheveux droits
d’épouvante, les paumes mouillées, me maintenant par miracle.
Je devais me tromper, rêver ! Ça ne pouvait être le possible.
Sous le grillage de fer, le cristal, intact, s’embuait. On eût dit qu’il
y avait de l’eau à l’intérieur de cette fenêtre-là.
C’était comme les parois d’un aquarium où nagerait le monstre
rare.
Mais on y voyait assez, tout de même, pour découvrir une longue
chevelure éplorée, blonde, décolorée, presque blanche, entourant
l’ovale d’un visage horriblement triste, un jeune visage de femme
contemplant la mer de ses yeux pleins de larmes…
Comme le soleil frappait sur ces yeux, ils brillèrent…
J’eus un étourdissement, et je me laissai aller, lâchant tout.
Je me tirai de l’océan sans trop savoir de quelle façon. Je suis
bon nageur. Seulement, dégringoler dans les courants d’Ar-Men,
c’est dégringoler dans la mort. Je filai au fond, je touchai le roc, puis
je remontai, ne pensant plus du tout, je vous jure, à la femme de là-
haut. Je redevins un brave animal d’homme qui essaye de se sauver,
et je me mis à nager ferme, tantôt dessus, tantôt dessous la vague,
m’efforçant de tourner dans la giration naturelle du courant,
n’espérant pas grand chose.
J’atteignis le bas de l’esplanade, et je fus roulé sur la pente,
repris, relancé par l’eau qui jouait avec moi comme avec un
bouchon.
Si la mer avait été plus violente, elle m’eût mis en morceaux,
mais elle venait de faire la noce, et elle semblait fatiguée de tuer du
monde.
Je me retrouvai presque debout devant l’escalier nord.
Alors mes dents claquèrent. J’eus un frisson, et je retombai sur
les dalles visqueuses, n’ayant plus ma connaissance.
Le vieux me soigna. (Quels soins, mon Dieu !)
Je passai huit jours au lit.
Il m’avait ramassé au bord du roc, ne comprenant pas pourquoi
j’étais étendu là, tout mouillé, paquet de linge sortant de la lessive.
La corde, pendant du chemin de ronde, lui expliqua la moitié de
la vérité.
— Ben, fit-il, durant que je rouvrais les yeux, ça t’apprendra, mon
garçon, à les choisir trop courtes.
Il me donnait des grogs dans lesquels il fourrait du poivre, un
remède infernal, et il y aurait ajouté volontiers un peu de pétrole
pour les corser en goût ; seulement, moi, malin, je refusai de boire.
J’avais peur de lui, une peur folle.
Il était celui qui guérissait des femmes !
Le médecin ne pourrait me visiter que lors du passage du Saint-
Christophe. On ne saurait donc rien ni de ma maladie ni de mon
probable trépas.
Et je me résolus à vivre coûte que coûte.
Un matin, je me levai, je fis mon service du mieux que je pus.
Le vieux me regardait, l’air moqueur :
— Te voici gaillard, eh ! eh !… faut toujours sauver sa peau,
même quand on n’a pas de chemise…
Il plaisantait, tournait autour de moi et paraissait meilleur
compagnon. Du grand navire perdu, pas un mot.
Les épaves demeuraient invisibles à l’horizon, et les noyés
(heureusement pour moi) avaient depuis longtemps gagné le large.
Le vieux, toujours à l’affut, son harpon dans la main, ne parlait pas
des belles filles recueillies.
Chose étrange, le souvenir de cette tête entrevue derrière la vitre
d’un hublot s’effaçait peu à peu de mon cerveau fatigué par l’éternel
bruit du vent. Je pensais avoir mal vu, des hallucinations, un rêve
continué tout éveillé. J’avais eu tant de rudes émotions la nuit du
naufrage. Pas étonnant si je battais la campagne. Un reflet bizarre
de soleil, le jeu d’une ombre entre les barreaux, mon propre visage
se mirant à une heure où j’étais plus nerveux que de coutume,
surtout éreinté par tant de manies ridicules…
Puisque je voyais des femmes dans tous les coins, le mieux serait
d’en aller chercher à Brest, où on les trouvait plus réellement.
Et ce fut, après ma maladie de langueur, une indomptable
résurrection de ma virilité.
On héla, du phare au Saint-Christophe, que le second gardien
sortirait.
— Ma pauvre vieille, répétait le maître de la chauffe, ma pauvre
vieille, ça ne va donc pas ?
Notre officier ajoutait, d’un ton sévère :
— Vous avez mauvaise mine, le Maleux !
A Brest, je ne reconnus pas une rue, que je connaissais pourtant
bien, parce qu’on avait achevé ses embellissements, des tas de
maisons neuves construites depuis mon dernier voyage.
Il me semblait que je revenais sur terre après ma mort.
Les gens avaient des habits singuliers, les femmes de la belle
société portaient des manches énormes, comme des ballons, et je
les avais laissées ayant encore des bras normaux.
Du côté du Minou, à la fine pointe de Brest, l’auberge-mercerie
était louée à deux cabaretiers mâles qui paraissaient plus ivres que
leurs clients, de sales rôdeurs mal vêtus.
J’entrai, je déjeunai et je demandai des nouvelles des anciennes
propriétaires de ce cabaret borgne.
— Ah ! la mère Bretellec, elle a rentré en ville, s’a mis fruitière.
— Et la petite Marie ?
— La petite Marie… sa servante ?
— Non, sa nièce.
— Nous ne connaissons point ça.
— Une fillette brune, insistai-je, le cœur douloureusement serré.
— Ben ! Elle aura peut-être mal tourné.
Ils se mirent à rire de mon air confus.
— C’est point si rare, que les filles tournent mal, camarade !
Je me retirai, n’osant pas en demander davantage.
J’errais de-ci de-là, comme un chien sans gîte. Je possédais de
l’argent, assez d’argent pour boire des consommations de choix, et
je bus.
Je choisis un grand café du côté de l’Arsenal, un café très chic où
venaient des officiers galonnés.
Je me fourrai derrière un pilier, un beau pilier habillé de velours
rouge et couronné par des crampons d’or, histoire de suspendre des
chapeaux. Bien respectueusement, j’y accrochai mon béret, puis je
sortis ma pipe, je fumai longtemps, face à face avec mon absinthe.
Je m’entourai de nuages, et la nuance verte du verre me donnait
une impression bizarre : j’étais devant un aquarium rempli d’eau
trouble, un visage mélancolique passait derrière les parois opalisées
du cristal.
Pour que la vision demeurât plus longtemps sous mes yeux
abrutis, je remplissais le verre très souvent. Puis je changeai la
nuance de l’eau, je mis des liqueurs de groseilles, des eaux-de-vie
brunes, des marcs blonds, aussi de temps à autre, pour imiter un
nuage ou du brouillard sur l’arc-en-ciel, un peu de la cendre de ma
pipe.
La nuit tomba. Il y eut des éclipses.
Je me trouvai au pied du phare qui était devenu tout rouge, un
phare sanglant couronné de grosses pointes d’or qui me menaçaient
comme des doigts en cornes ; j’essayai de grimper pour prendre
mon béret pendu à l’une de ces cornes, non, jamais je ne pourrais
l’atteindre !
— Ho ! Hisse ! Hisse en haut ! Je peux pas, nom de nom !
Et je faisais le geste de tirer sur le palan de la grue d’arrimage.
Un garçon me poussa dehors, après m’avoir extirpé une forte
somme. Je m’en allai, chantonnant le refrain du père Barnabas. Pas
heureux, pas malheureux non plus, ne pensant ni aux promises, ni
aux filles. Je m’en allai, ruminant des imbécillités.
— Est-ce qu’il fera beau demain ? Si je m’achetais du savon ? Ce
qu’elle doit s’embêter derrière la vitre, la tête de la mer !… Pas
moyen de grimper… mais quelle noce quand on la descendra !
Mazette ! Y se met bien le vieux ! Des demoiselles blondes dans la
prison de la marine… que le diable en prendrait les armes ! J’en aurai
le cœur net… faudra voir… Jean Maleux, marche droit ! Je te le dis,
t’es né sous la chance.
Malgré moi je quittais les quartiers riches pour gagner les petites
ruelles derrière l’Arsenal. Je connaissais la route par cœur, pour
l’avoir faite jadis quand je revenais de caboter avec le capitaine
Dartigues.
J’étais donc jeune, alors, que j’y mettais plus d’entrain ?
Je restais jeune, seulement la mer m’avait imprégné jusqu’aux
moelles de sa mélancolie, surtout depuis le jour où j’avais failli
sombrer en elle, corps et âme.
J’entrai dans une maison dont la porte, grande ouverte, bâillait
comme une gueule de loup féroce.
A l’intérieur, c’était tendu de rouge. Le rouge me poursuivait,
piquant mon regard de ses milles aiguilles trempées dans le vinaigre.
J’en avais bu et j’en rencontrai sur les piliers de café, sur les robes
des dames, dans les lanternes des voitures, maintenant le long des
murailles. C’était doux à toucher, c’était tiède, c’était bon…
J’entendis des voix chuchoteuses. On m’appelait : beau brun.
J’étais plus habitué à tant de politesse.
Je voulus ôter mon béret, et je m’aperçus que je l’avais perdu.
Des tas de grosses filles se moquèrent de moi, parce que je
cherchais mon béret : elles me bourraient, me pinçaient, me
tapaient dans le dos, me faisaient monter, descendre. Ce que je leur
fis, je n’en sais rien ! La patronne se fâcha et me jeta dehors.
J’entrai comme ça dans plus de cinq maisons qui, toutes,
ouvraient des grandes gueules rouges pour me happer, et, dans un
cabaret, des matelots, déjà terriblement saouls, m’invitèrent à boire
davantage.
Il s’agissait du Marceau, un cuirassé prenant la mer, et nous
chantâmes des complaintes lugubres en son honneur. C’est-y la mer
qui le prendrait ?
Je voyais filer à toute vitesse ce grand cheval noir de navire qui
s’était broyé sur la Baleine, par le travers de chez nous, et que les
autorités essayaient de repêcher du côté du Fromveur. Pour son
équipage, personne n’en causait plus.
Des idées formidables me tenaillaient le cerveau : faire la guerre
à la mer, étrangler la mer, couper sa tête.
Je serrais mon eustache sous ma ceinture. Je voyais du rouge
couler du plafond de la salle où nous buvions.
De nouveau, dans la rue, lâchant les camarades, je festonnais,
battant les murs. Ça tournait d’une façon vertigineuse. Plus aucun
bec de gaz, plus de lanternes de voitures, plus de phares sauveurs.
Je n’arriverais jamais nulle part cette nuit-là.
On entendait s’éloigner les chansons, les rires, les cris. J’étais
dans une petite ruelle infecte, marchant dans une boue vaseuse,
sentant la marée, une petite ruelle du côté, je pense, des bastions
de la ville.
Je me la rappellerai toujours cette petite rue-là… quand je
devrais vivre cent ans.
Elle se trouvait tellement étroite, tellement sombre que l’on n’y
aurait point reconnu son père, même en plein jour. Là-haut, tout là-
haut, les toits des maisons semblaient se rejoindre. Un ruisseau
clapotait, provenant bien sûr des bassins où l’on radoube — on s’en
doutait rien qu’à ses odeurs — ces trous où l’on jette plus de chats
crevés que de pelures de pommes.
Là aussi des portes s’ouvraient, se fermaient, happant les
promeneurs nocturnes, seulement les maisons étaient moins
luxueuses, et, dans quelques-unes, des filles exploitaient les pauvres
matelots, sans garantie du gouvernement.
Je ne sais pas pourquoi, j’eus peur tout d’un coup, une peur
inexplicable. Je serrais mon couteau. Je serrais mon couteau, en
pensant marcher à la bataille.
Toutes les caresses des bonnes putains, là-bas, parmi les fleuves
rouges des étoffes, ne m’avaient ni apaisé ni dégrisé ; tout le tapage
des joyeux compagnons, les marins du Marceau, me restait au fond
des oreilles comme des bruits de guerre. Contre qui, contre quoi
fallait-il s’armer, se battre ?… Et très loin, très haut, plus haut que les
maisons se rejoignant dans les ténèbres, girait un phare électrique
dont les rayons blancs fouettaient le ciel de fouets livides
m’éblouissant sans éclairer ma route.
Le plus étonnant, c’est que je me croyais en mer. J’allais au phare
d’Ar-Men, je me dirigeais vers la Tour d’Amour, et je traversais
l’océan à pied, n’ayant plus besoin de m’embarquer sur le Saint-
Christophe. J’entendis qu’on marchait derrière moi.
Un trot de souris. Le pas de quelqu’un qui se dissimule.
— C’est le vieux, que je me dis !
Ça n’avait aucune raison de songer au vieux, puisque c’était une
femme. Elle me posa la main sur la manche :
— Petit homme, qu’elle me dit.
Je fus envahi par une colère folle :
— Petit homme ? Moi, Jean le Maleux ! J’en vaux bien trois pour le
service, et je me suis battu avec la mer. Faut pas me traiter de petit
homme… Je reviens de trop loin.
La fille, peut-être aussi grise que moi, peut-être parce que mes
paroles lui rappelaient un son de voix déjà entendu, se précipita
brusquement dans mes bras, s’agrippa — telle une pieuvre — à mes
épaules et me baisa sur la bouche d’un long baiser, suceur,
abominable, puant le musc.
— Toi, tu n’embrasseras plus jamais plus personne ! C’est fini de
rire, sale gueuse !
Et je lui plantai mon couteau dans le ventre.
Elle tomba. Je continuai mon chemin, ne me retournant même
pas, marchant d’une enjambée plus ferme, plus digne, enivré d’un
grand orgueil.
— Ben, quoi ? J’ai tué la mer !
XII

— Encore un cauchemar ! que je pensais durant des semaines.


Mais la disparition de mon béret me tourmentait. J’avais perdu
mon béret dans ma course à travers les rues chaudes de la basse
ville de Brest, et puérilement, limant toujours le bouton de ma veste,
je songeais qu’il me faudrait en racheter un autre ou… voir revenir
l’ancien chez nous rapporté par la police.
Ça, c’était une preuve contre moi.
Je n’avais probablement tué personne. Les filles sont habituées
aux coups de couteau des galants de la mer…
Celle-là vous embrassait comme la petite Marie. (Encore un
rêve ? Comment la petite Marie, ma promise, aurait-elle pu se
transformer en fille pour…)
Je ne ressentais ni chagrin, ni remords. Je ne pensais, ni
n’agissais plus de mon plein consentement.
Puis, j’étais pris de boisson, cette nuit-là…
Mon béret ne revint jamais.
J’en fis acheter un autre.
Et des semaines, des semaines coulèrent, des mois. Noël,
Pâques, l’Ascension, l’Assomption. Je n’entendais point leurs cloches.
Le Saint-Christophe passait, sifflait son appel à la vie devant la
maison de la mort.
Je ne répondais pas, las d’essayer de vivre.
Nous demeurions les deux ours en cage, le vieux et moi, parlant
juste pour le besoin du service, nous cachant nos manies secrètes,
lui, déclinant peu à peu vers sa fin, car il n’étudiait même plus
l’alphabet, moi farouchement reconquis par d’infernales habitudes.
On mangeait, on buvait, se remontant comme des horloges tous
les matins, excellentes mécaniques de l’aurore au crépuscule, et se
détraquant toutes les nuits, après les premiers jets de feu du phare.
On faisait son devoir d’éclairer le monde… en aveugles.
Le devoir, c’est une manie, la plus terrible des manies, car on a
confiance en elle. On s’imagine qu’elle vous sauvera.
La conscience de mon crime ne me rentra au ventre que le jour
où le vieux chut sur l’esplanade, terrassé par un mal singulier.
Il fumait sa pipe tout debout, le dos contre la muraille du phare,
les pieds se mouillant dans l’écume qui déferlait rageusement
jusqu’à lui.
Moi, je mâchais du tabac, assis sur le parapet du côté nord, et je
le regardais comme étonné de le voir si grand.
Depuis que je ne lui adressais plus la parole que dans les
occasions solennelles et que j’avais réparé seul notre brèche de la
cinquième meurtrière, moyennant le ciment envoyé du Saint-
Christophe, il semblait me conserver rancune.
Mais il restait toujours vaillant à la besogne, les temps de
bourrasques ; d’ailleurs, il m’avait garé du vent le soir du navire en
perdition… et on s’estimait.
… Quel navire ? Je ne me souvenais pas bien.
Tous les navires se perdaient par chez nous.
Nous habitions la Tour d’Amour !
Mathurin Barnabas était grand, maigre et grand comme le phare,
il ne se voûtait que pour flairer les épaves.
Sa figure blafarde, son nez camard, ses yeux sanglants qui
pleuraient, maintenant, des espèces de glaires lumineuses, son haut
front chauve, lui donnaient l’aspect d’un fantôme de chrétien, un
matelot péri au loin qui revenait pour torturer les autres, car on
l’avait dû faire sombrer trop tôt, un boulet aux chevilles, histoire de
s’en débarrasser.
Il fumait, crachotant le long de ses habits tellement sales,
tellement déchirés qu’on respirait, près de lui, une odeur affreuse.
Il puait le cimetière.
Moi, je continuais à me tenir propre. (Peut-être bien que je
m’aimais encore un brin.) Lui ne s’aimait plus, n’aimait plus ses
compagnons, n’aimait plus les noyées. Il guettait seulement la venue
de la dernière marée… celle qui apporte le dernier navire pour le
dernier voyage entre les quatre planches. Je calculais qu’il pouvait
bien avoir la soixantaine.
— Peut-être ben que oui ! Peut-être ben que non, m’aurait-il
répondu, s’il avait su encore parler.
Mais il ne proférait plus que des sons bizarres, des grognements
de porc sauvage qu’on ne comprenait guère, s’il ne les accentuait
d’un geste.
Il fumait…
Tout à coup il s’abattit, le front en avant, sur les dalles de
l’esplanade toujours glissantes, et il allait gagner le large.
— Père Mathurin ! Eh ! père Barnabas !…
Je le relevai, le prenant à bras le corps. Je le trouvai lourd
comme du plomb.
Ses jambes ne remuaient pas, tendues, tirées par des cordes
invisibles, ses bras mous ballottaient autour de son corps, n’essayant
pas de chercher un appui. Seule, sa tête vivait, et ses yeux, ses
pauvres yeux abominables, lancèrent une lueur verte.
— La barque ! dit-il distinctement.
— Quelle barque, père Mathurin ?
Moi aussi j’avais maintenant envie de parler.
Je tremblais de tous mes membres.
Je l’accotai au parapet, je courus chercher une fiole d’eau-de-vie
et je le fis boire.
Ses dents, très serrées, brisèrent le goulot de cette bouteille, il
avala autant de verre cassé que de liqueur.
— Voyons, père Barnabas, faut pas se laisser crever sans les
sacrements… Le Saint-Christophe est venu hier… il ne repassera que
dans quinze jours. Que diable… vous m’entendez, hein ?
Il fit signe que oui, hocha la tête et eut, cela m’étonna, son rire
cynique des temps d’orage.
Jusqu’au soir je m’évertuai à lui ranimer les jambes. C’était pis
que des morceaux de bois.
La paralysie, probablement.
J’avais encore de l’espoir, rapport à la tête qui continuait à virer
sur son cou. Je lui enfonçai sa casquette, le recouvris de sa vieille
couverture de lit sentant l’huile de poisson, et je le quittai, une
heure, pour allumer les lampes là-haut.
En montant la spirale, mon cœur battait fort. Je me souvenais de
sa phrase :
— Souhaite, le Maleux, que je ne meure point durant l’été, après
le passage du ravitailleur…
Et je me rappelais aussi sa drôle de recommandation de l’arroser
d’alcool.
Enfin, quoi, il n’allait pas pourrir quinze jours à côté de moi, lui
qui pourrissait déjà au fond du charnier de son âme depuis tant
d’années ?…
Ah ! bien non, je le jetterais plutôt dans l’océan.
Cas de force majeure, n’est-ce pas ?
A la mer comme à la mer !
Lorsque je redescendis, je le retrouvai couché, bien sage, ne
remuant ni pieds ni doigts.
Ses yeux se fixèrent sur les miens, affectueusement, d’une
couleur toute tendre, il me dit, d’un accent que je ne lui avais jamais
entendu :
— Mon pauvre Jean, je suis fini.
Ce fut comme si mon père, mon vrai père, me parlait.
Je me mis à genoux près de lui, pleurant et oubliant mes
réflexions égoïstes.
— Ben non, c’est pas une raison, l’ancien, pour vous effrayer, vos
jambes vont vous revenir. On n’est pas fini pour une chute, un
simple étourdissement. A votre âge… on se frappe, mais… quoi, je
suis là pour vous soigner… On ne se parle guère… mais on se
comprend, mon pauvre vieux. Le malheur nous tient depuis
longtemps les mains l’une dans l’autre.
Il essaya de se remuer, retomba, racla la pierre de ses ongles et
du bout de ses bottes.
— Faut me mettre sur mon lit, mon gars, dit-il de sa voix de plus
en plus claire, et me frotter avec du pétrole. Un bon remède. Faut
tout essayer. Je tiens point à te laisser dans l’embarras, le Maleux.
Il songeait à mon embarras, tout près de sa propre mort.
Je fus si touché que mes larmes ruisselèrent.
Mon cœur crevait avec lui.
Dame, on avait vécu bientôt six ans ensemble.
Ennemis ? Non ! Seulement étrangers.
— Père Mathurin, dites-moi ce qu’il faut faire. Je vous obéirai.
Je le traînai, ce grand cadavre qui causait, retrouvant la vie de la
raison, et je le plaçai sur sa couchette, en face de notre foyer.
Il voulut boire, je lui offris du vin.
— Non, fit-il, donne-moi de l’eau…
Il en but deux gorgées.
— Elle est amère, l’eau, murmura-t-il. Est-ce qu’elle est toujours
comme ça ici ?
Lui n’en buvait jamais.
— Elle est douce, père Mathurin… d’ordinaire. Voulez-vous du
sucre ?
— Non, merci.
Et ses yeux se fermèrent un instant.
Il avait dit : merci ! Je ne savais plus quoi inventer pour le
remercier à mon tour de se montrer brave homme.
Ce n’était pas sa faute s’il était si sale.
Ce n’était pas sa faute s’il était si méchant.
Quelque chose avait dû passer sur lui, l’éteignant, et glaçant la
meilleure vigueur de son sang.
Le pauvre…
Son grand corps, étendu au milieu de notre salle basse,
paraissait s’écraser sous l’énorme colonne du phare.
On l’avait muré là, et il portait le lourd flambeau de toute la
dernière force de sa poitrine d’homme.
Maintenant ma poitrine, plus jeune, allait remplacer la sienne, et
je sentais déjà le fardeau m’accabler, sans d’ailleurs aucune idée de
me soustraire à ce devoir.
Quand on reste longtemps à la même place, on aime l’endroit où
l’on souffre. C’est plus naturel que de chercher le bonheur.
Je pensai qu’il voulait dormir et je vins bourrer une pipe sur
l’esplanade.
Il faisait une belle soirée d’automne, en supposant qu’on puisse
dire que la mer est belle quand elle est rouge, toute teintée par le
soleil couchant, comme par la fureur d’un incendie. Les vagues
ondulaient, grosses, opulentes, dans un tel luxe de soieries et de
bijoux qu’elles offensaient notre misère. Ah ! les gueuses, les
gueuses ! Tous leurs petits ronrons de chatte, leurs cris de lionnes
enragées, leurs danses de comédiennes et, pour finir, les torrents de
sang et de larmes ruisselant autour d’elles sans paraître les salir.
Belles de toutes les libertés que les hommes prisonniers de leurs
volontés sont obligés d’admirer de loin !
On veille sur elles et elles avalent les grands navires ; on leur
confie sa destinée, et elles vous noient entre leurs seins mouvants.
Cela jouait, se poursuivait, hurlait des mots obscènes, ou chantait
des cantiques, mais cela, par-dessus tout, vivait de la mort des
autres.
Une odeur de marée entrait chez nous avec le vent pur, une
odeur impure, âcre, gerçant les lèvres qui en goûtaient la saveur
excitante, fendant la peau de rides précoces, emplissant les regards
du sel dont on fabrique les larmes de désespoir.
La mer était belle, la mer dansait au soleil couchant, et relevait
sur les marches de l’escalier du phare ses franges d’écume comme
une fille exhibe son linge.
Bientôt nous aurions besoin de linge, en effet, et je pensais que
nous ne possédions point de drap neuf pour un linceul décent.
— Le Maleux ?
Je me retournai.
Le père Barnabas s’était presque dressé sur son lit. Il devenait
plus pâle, et ses yeux se creusaient horriblement dans sa face livide.
— Jean, tu es un bon compagnon, quoique ben jeune pour
tolérer ça… Jean, faut tout prévoir… Je peux sombrer… Je sens plus
mes genoux… tâte voir le cœur… Est-ce que ça bat toujours ?
Je lui touchai la poitrine.
— Vous êtes fou, l’ancien. On ne meurt point d’une attaque… il
en faut trois. D’ailleurs, je vais mettre un pavillon en berne et si une
barque…
Il tressaillit douloureusement.
— La barque ! La barque ! répéta-t-il.
— Quelle barque, père Mathurin ?
Il se penchait pour regarder la mer, semblant guetter réellement
une voile.
La mer dansante ne faisait danser personne.
— V’là que ça le reprend ! soupirai-je.
Je le veillai, immobile à côté de lui, les bras croisés.
C’était l’agonie qui arrivait. Il ne verrait point la troisième
attaque, et je resterais en tête à tête avec un cadavre, cette fois,
tout à fait mort.
Quinze jours… sans pouvoir l’enterrer !
— Mon Dieu, dis-je tout haut, protégez-nous !
Dieu nous protégeait visiblement, car il nous faisait grâce de la
tempête. Là-haut, les lampes flambaient tranquillement, durant que
le gardien-chef coulait sa dernière huile.
Vers minuit, comme je descendais de la lanterne, le vieux me
sembla presque bien. Ses yeux se remirent à me chercher, et sa voix
s’adoucit :
— Est-ce que ce serait de bonne amitié que tu me rendrais un
service, le Maleux ?
Je m’assis sur son lit, et je dis oui, du front.
— T’auras pas peur ?
— J’ai plus peur de rien, déclarai-je d’un ton résolu.
— Alors… va me la chercher…
Je fus debout, tout de suite, et je m’écriai :
— Qui ? La femme ?
— Oui, la femme, puisque tu l’as vue…
Je frissonnais de tout mon corps. Il n’était pas fou… je n’étais pas
fou…
Nous avions tué chacun une femme que nous aimions, étant
ivres, ou d’amour ou de vin…
Mon crime, demeuré enseveli au fond de ma conscience,
ressuscitait, et je retrouvais la preuve du mien avec la certitude du
sien.
— Père Barnabas… excusez-moi… j’ai cru voir sa tête… un jour
d’y a longtemps, derrière la vitre d’une des meurtrières…
— Tu es jeune… tu ne comprendras pas… c’est des appétits de
vieux, et puis… autrefois… la vivante… elle m’avait fait cocu… J’ai
jamais pu aimer que celle-là, par orgueil… Faut aller me la chercher,
et tu la jetteras dans la mer quand je serai fini.
Il m’indiqua la poche de cuir de sa ceinture, qui ne le quittait
jamais. J’y puisai une clé toute chaude encore du contact de sa
chair.
Il me fit un signe.
Mais j’étais déjà parti. Je savais bien le chemin.
Je montai, m’appuyant au mur, suffoquant et tendant ma lampe
bien en avant comme pour me défendre.
Vers la moitié de l’escalier, je m’arrêtai contre la porte
mystérieuse.
Oh ! pas plus mystérieuse que les cinq portes aux cinq étages de
la tour.
Je posai ma lampe et j’introduisis la clé.
Ça s’ouvrit très doucement.
… De la poussière, un peu de sable, de ce sable fin qui pénètre
partout, si blanc, si fluide. Pas de femme ! Aucun cadavre, aucun
squelette ; seulement, sur l’appui de la fenêtre, juste devant la loupe
de verre, voilée d’une buée verte, une étrange plante dans un pot de
cristal, un large pot où l’on met des gros fruits à confire… et les
poisons, chez les pharmaciens.
Cette plante s’étalait autour du pot en luxuriants rameaux blonds,
était onctueuse au toucher, très pareille à des cheveux.
Retournant le bocal, je vis la tête osciller légèrement, et ses yeux
vides s’emplirent de lueurs, s’irisant à travers l’alcool.
Je jetai ma veste sur elle, pour ne plus rencontrer ses yeux en
l’emportant.
… Le vieux caressa, de ses larges pinces de crabe, cette
chevelure fusant d’une rondelle de liège, en cascades légères, puis il
dit, très distinctement, durant que je me cachai la figure dans ses
draps :
— Ben quoi, petit ? Fais pas l’enfant !… Elle a été belle… je t’en
réponds, elle ne l’est plus… mais c’est que tu n’as pas connu son
corps… Aucune autre créature n’a été si bonne pour moi, le pauvre
bougre abandonné… elle est venue comme un ange quand je me
rongeais les sangs attendant la marée montante. Elle est venue
suivant une barque chavirée… morte à peine depuis deux jours, pas
enflée, pas verdie, toute jeune la pauvre garce… et vierge… une
demoiselle riche. Elle était accrochée par ses cheveux au gouvernail
de la barque… des cheveux plus blonds, plus épais… (je lui en ai pris
deux touffes près des oreilles, je les aimais tant…) Ils avaient encore
un parfum de fleur… des fleurs de la terre… je l’ai gardée une lune…
puis j’ai coupé la tête… pour mon dessert d’amour. Oui, bien bonne,
bien douce, bien complaisante ! Cependant, elle m’a fait tuer
quelqu’un, celui d’avant toi, un garçon sensible qui, rien que de
l’avoir aperçue, s’est suicidé. Il s’est guéri, quoi ! Maintenant… faut la
rendre à l’Océan. Car… je suis jaloux. Va !…
Je me relevai ; tout courant, j’allai précipiter cela du haut des
escaliers de l’esplanade. Le bocal se brisa, rendant un son sinistre de
vitre éclatant sous un poing, et la tête, enfin libre, sombra au plus
profond des abîmes.
Quand je rentrai, le vieux riait d’un rire presque paisible, ses
puissantes mains posées bien à plat sur sa poitrine, et il ne respirait
plus.
Lui aussi était guéri !
Je récitai la prière des morts que tous les gens de mer, qu’ils
croient en Dieu ou qu’ils se donnent au diable, savent par cœur.
Je récitai la prière des morts dans ma grande solitude peuplée de
fantômes…
… Au bout de trois jours, je l’arrosai de pétrole.
… Le cinquième jour, je l’entourai de tous ses habits, et je le
cousis dans ses draps hermétiquement.
… Vers le huitième jour, ne mangeant plus, ne buvant plus, je
m’enfermai chez moi, je bouchai la porte de l’escalier, et je passai le
temps au soleil, sur le chemin de ronde.
Mais il fallut descendre pour chercher des provisions de torches,
en cas de grain.
Le long de la spirale, c’était comme l’haleine de la peste.
Le courage me manqua. J’eus l’idée sacrilège de le lancer à l’eau,
bourré de limailles et de plomb.
Non ! Je ne devais pas… il avait encore bien besoin de prière. Je
ne devais pas…
Je l’exposai, comme un ballot, dans le coin nord de l’esplanade.
Ce supplice dura les quinze jours prescrits.
Des vers grouillaient, gras de graisse humaine, sur le ballot…
— Navire !…
Je hurle, je saute d’impatience.
C’est le Saint-Christophe.
On m’envoie un camarade, le remplaçant des jours de sorties.
Et les autorités débarquent : un officier tout galonné, l’air
sérieux, le commandant, le médecin et le prêtre.
Le palan les amène un à un, d’abord comme des petits pantins
ridicules, ensuite, les pieds sur les dalles du phare, plus grands, plus
solennels.
Toutes ces figures de compassion m’émeuvent, et j’ôte mon
béret, bien honnêtement.
Je suis un criminel devant ses juges.
Je m’explique et je pleure.
— Allons ! Allons, le Maleux, fait l’officier, vous êtes un brave
garçon… vous avez eu du courage… oui… une terrible situation
quinze jours au large, sans un aide… Vous serez récompensé !…
Il parle pendant une heure. Les oreilles me saignent. Il nous
réunit autour de ce ballot qui pue et nous apprend que ce fut un
homme…
— Trente ans de services ! Un luron, mes amis. Que Dieu ait son
âme. Vous, le Maleux, vous voilà gardien-chef.
Le curé s’agenouille.
Nous pleurons tous.
Et ils s’en vont, d’abord solennels, ensuite petits pantins pendus
au bout du fil de la providence.
— Ho ! hisse ! hisse en haut !
Nous halons ferme, mon aide et moi, ragaillardis un peu par une
goutte bue et trinquée avec les patrons.
Je suis nommé gardien-chef.
Marie, ma chère petite Marie…
Devant Dieu, s’il m’écoute, je jure de ne jamais revoir la terre.
XIII

… Alors, comme j’ai peur, moi aussi, d’oublier l’alphabet, je me


suis mis à écrire mon histoire sur le grand livre du phare. Je
mentionne les navires perdus, les barques de pêche, passant le
ventre en l’air, et, un à un, tous mes souvenirs d’amour qui sombrent
dans l’éternelle tristesse.
Mais je fais mon devoir malgré moi.
Je demeure solide au poste.
L’idée fixe du devoir, c’est le commencement de la folie.
… Et je suis fou, car je n’espère plus rien, je n’attends plus rien…
pas même la belle noyée de la marée montante !…
*** END OF THE PROJECT GUTENBERG EBOOK LA TOUR D'AMOUR
***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like