Skip to content

Commit 4959d50

Browse files
Merge pull request #25 from alexanderthclark/cleanup-small-book-fixes
Fix small book errata and reproducibility gaps
2 parents 4389aca + c43ecb6 commit 4959d50

10 files changed

Lines changed: 20 additions & 16 deletions

File tree

‎Data/readme.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Data
22

3-
This folder contains CSV files used in the examples throughout *Matplotlib for Storytellers*. All of the files were downloaded from [Google Trends](https://trends.google.com) and contain normalized search interest values ranging from 0–100. The data is provided here for educational use and remains subject to Google's Terms of Service.
3+
This folder contains CSV files used in the examples throughout *Matplotlib for Storytellers*, including Google Trends search interest and NHL regular-season standings. The [Google Trends](https://trends.google.com) files contain normalized search interest values ranging from 0–100. That search interest data is provided here for educational use and remains subject to Google's Terms of Service.
44

5-
## Files
5+
## Google Trends files
66

77
- **AristotleSparkNotesTrends.csv** – Weekly U.S. search interest for "Aristotle" and "SparkNotes" from January 2019 through December 2020.
88
- **SparkNotesFall2019.csv** – Daily U.S. search interest for "SparkNotes" covering August–December 2019.
99
- **finalFourTrend.csv** – Monthly U.S. search interest for "Final four" from January 2004 through July 2021.
1010
- **HopperOstromTrends.csv** – Monthly U.S. search interest for "Grace Hopper" and "Elinor Ostrom" from January 2004 through July 2021.
1111
- **WeatherAug1415Trends.csv** – Minute-level search interest for "weather" collected August 14–15, 2021 (time zone −04:00).
1212

13+
## NHL data
14+
15+
- **nhl_regular_season.csv** – Final regular-season standings for six NHL teams from 1999–00 through 2008–09, retrieved from the [official NHL standings API](https://api-web.nhle.com/v1/standings-season) using [`fetch-nhl-standings.py`](../python/fetch-nhl-standings.py). Includes season and end date, team name and abbreviation, games played, points, and points percentage (`points / (2 × games played)`, on a 0–1 scale). The cancelled 2004–05 season has no rows because of the league-wide lockout.

‎environment.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ dependencies:
3636
# Additional pip packages
3737
- pip:
3838
- sphinx-proof>=0.1.3
39-
# - ternary # Uncomment if needed for ternary plots
39+
- python-ternary

‎jupyterbook/chapter4/index.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ Matplotlib offers `text` as both a figure and an axes method. Let's start with s
5252

5353
Immediately, we see that despite passing the same $x$ and $y$ position values, the figure and axes methods place the text differently. By default, the figure method uses "figure" coordinates, where (0,0) is the bottom left and (1,1) is the top right. The axes method uses $x$ and $y$ data coordinates by default. We will modify this shortly.
5454

55-
A more common concern is the alignment of the text. Both figure and axes text methods include parameters `verticalalignment` and `horizontalalignment`, which can be abbreviated as `va` and `ha`. By default, the text is placed so that the given coordinate is at the bottom-left corner of the text.
55+
A more common concern is the alignment of the text. Both figure and axes text methods include parameters `verticalalignment` and `horizontalalignment`, which can be abbreviated as `va` and `ha`. By default, the text starts at the given horizontal coordinate, with its baseline at the given vertical coordinate.
5656

5757
```{literalinclude} ../../python/text-default-align.py
5858
:language: python
5959
```
6060

6161
![Default text alignment](../images/chapter4/text-default-align.png)
6262

63-
For vertical alignment, the options are `'top'`, `'bottom'`, or `'center'`. For horizontal alignment, the options are `'left'`, `'right'`, or `'center'`. The default demonstrated above was `'bottom'` and `'left'`. It does result in the text being above and to the right of the coordinate point, perhaps confusingly, but the interpretation is that the coordinate point is at the bottom-left of the text. The possible alignments are illustrated below.
63+
For vertical alignment, the options are `'top'`, `'bottom'`, `'center'`, `'baseline'`, or `'center_baseline'`. For horizontal alignment, the options are `'left'`, `'right'`, or `'center'`. The default demonstrated above was `'baseline'` and `'left'`. The coordinate point is at the left edge of the text's baseline. Some of the possible alignments are illustrated below.
6464

6565
```{literalinclude} ../../python/text-align.py
6666
:language: python
@@ -267,4 +267,4 @@ After you've downloaded a font family, you should have folder for that font with
267267
:language: python
268268
```
269269

270-
![Font example](../images/chapter4/font.png)
270+
![Font example](../images/chapter4/font.png)

‎jupyterbook/requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pandas>=2.0.0
1010
scikit-learn>=1.8
1111
scipy>=1.10.0
1212
statsmodels>=0.14.0
13+
python-ternary
1314

1415
# Image processing
1516
Pillow>=9.5.0

‎main.tex‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ \chapter{Style Configuration}\label{chapter:styconfig}
119119
% Math interlude
120120

121121
\cleardoublepage
122-
\epigraphhead[200]{\vspace{5cm}\hfil\includegraphics[width = .65\textwidth]{Images/venicefloor.jpg}\hfil\\
122+
\epigraphhead[200]{\vspace{5cm}\hfil\includegraphics[width = .65\textwidth]{images/venicefloor.jpg}\hfil\\
123123
\begin{center}St Mark's Basilica, Floor mosaic by Paolo Uccello (Public Domain)\end{center}}
124124
% https://commons.wikimedia.org/wiki/File:Marble_floor_mosaic_Basilica_of_St_Mark_Vencice.jpg
125125

@@ -130,7 +130,7 @@ \part{Mathematical Interlude}\label{part:math}
130130
% Poetry
131131

132132
\cleardoublepage
133-
\epigraphhead[200]{\vspace{4cm}\hfil\includegraphics[width = .9\textwidth]{Images/NewtonBlake.jpg}\hfil\\
133+
\epigraphhead[200]{\vspace{4cm}\hfil\includegraphics[width = .9\textwidth]{images/NewtonBlake.jpg}\hfil\\
134134
\begin{center}\emph{Newton} by William Blake (Public Domain)\end{center}}
135135
% https://en.wikipedia.org/wiki/File:William_Blake_-_Newton.png
136136

@@ -246,4 +246,4 @@ \chapter*{About the Author}
246246

247247

248248

249-
\end{document}
249+
\end{document}

‎requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ pillow
77
scikit-learn>=1.8
88
scipy
99
statsmodels
10-
ternary
10+
python-ternary

‎tex/copyright.tex‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
\begin{figure}
22
\centering
3-
\includegraphics[width = .3\textwidth]{Images/by-nc-sa.png}
3+
\includegraphics[width = .3\textwidth]{images/by-nc-sa.png}
44
%\caption{Caption}
55
%\label{fig:my_label}
66
\end{figure}
77

88
\noindent This text is released under the \link{https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en}{Creative Commons Attribute-NonCommercial-ShareAlike 4.0 International} License.
99

1010
\smallskip
11-
\noindent The code is released under the MIT license.
11+
\noindent The code is released under the MIT license.

‎tex/prose/dates.tex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ \subsection{Date Formats}
5050
\code{'\%B'} & Month Name \\
5151
\code{'\%H'} & 24-Hour Clock Hour \\
5252
\code{'\%M'} & Minute \\
53-
\code{'\%H'} & 12-Hour Clock Hour \\
53+
\code{'\%I'} & 12-Hour Clock Hour \\
5454
\code{'\%p'} & AM or PM \\
5555
\code{'\%A'} & Day of Week \\
5656
\code{'\%Z'} & Timezone Name \\

‎tex/prose/styconfig.tex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ \section{A Final Prose Example}
101101
In this section, we'll integrate much of what we've learned so far to create a line chart that, though simple, is far from the default. We'll imitate a chart from the New York Times article, \emph{The Pandemic Changed How We Spent Our Time}, by Ben Casselman and Ella Koeze. Below is the original.
102102

103103
\begin{center}
104-
\includegraphics[width = .8\textwidth]{Images/nytATUS.png}
104+
\includegraphics[width = .8\textwidth]{images/nytATUS.png}
105105
\end{center}
106106

107107
Imitating this graphic will take a lot of code, as demonstrated in Section \ref{subsec:firstgo}. In Section \ref{subsec:rrr}, we invest in reconfiguring the style and creating functions that help reduce the tedium that would otherwise be required to make several plots of this style.

‎tex/prose/titles.tex‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ \section{Text and Placement}\label{sec:textplacement}
4040

4141
Immediately, we see that despite passing the same $x$ and $y$ position values, the figure and axes methods place the text differently. By default, the figure method uses ``figure'' coordinates, where (0,0) is the bottom left and (1,1) is the top right. The axes method uses $x$ and $y$ data coordinates by default. We will modify this shortly.
4242

43-
A more common concern is the alignment of the text. Both figure and axes text methods include parameters \code{verticalalignment} and \code{horizontalalignment}, which can be abbreviated as \code{va} and \code{ha}. By default, the text is placed so that the given coordinate is at the bottom-left corner of the text.
43+
A more common concern is the alignment of the text. Both figure and axes text methods include parameters \code{verticalalignment} and \code{horizontalalignment}, which can be abbreviated as \code{va} and \code{ha}. By default, the text starts at the given horizontal coordinate, with its baseline at the given vertical coordinate.
4444

4545
\pyfile{text-default-align.py}
4646

4747
\begin{center}
4848
\includegraphics[width = 0.5\textwidth]{figures/proseplots/text-default-align.pdf}
4949
\end{center}
5050

51-
\noindent For vertical alignment, the options are \code{'top'}, \code{'bottom'}, or \code{'center'}. For horizontal alignment, the options are \code{'left'}, \code{'right'}, or \code{'center'}. The default demonstrated above was \code{'bottom'} and \code{'left'}. It does result in the text being above and to the right of the coordinate point, perhaps confusingly, but the interpretation is that the coordinate point is at the bottom-left of the text. The possible alignments are illustrated below.
51+
\noindent For vertical alignment, the options are \code{'top'}, \code{'bottom'}, \code{'center'}, \code{'baseline'}, or \code{'center_baseline'}. For horizontal alignment, the options are \code{'left'}, \code{'right'}, or \code{'center'}. The default demonstrated above was \code{'baseline'} and \code{'left'}. The coordinate point is at the left edge of the text's baseline. Some of the possible alignments are illustrated below.
5252

5353
\pyfile{text-align.py}
5454

0 commit comments

Comments
 (0)