View tufte5.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create data | |
x = list(range(1951, 1960)) | |
data = [] | |
data.append({'label': 'New York', 'x': x, 'y': [ | |
13.8, 13.6, 14.3, 13, 13.6, 13.5, 13.4, 13, 12.6]}) | |
data.append({'label': 'Massachusetts', 'x': x, 'y': [ | |
10.1, 10, 11.5, 10.8, 11.7, 11.50, 10.1, 11.8, 10.7]}) | |
data.append({'label': 'Connecticut', 'x': x, 'y': [ | |
12.7, 10.9, 12.5, 11, 14.3, 12.4, 11.8, 10.2, 9.7]}) | |
data.append({'label': 'Rhode Island', 'x': x, 'y': [ |
View tufte4.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# plot data | |
# add two layers of points to create an illusion of a discontinuous line. "zorder" specifies plotting order | |
ax.scatter(x, y, s=64, color='white', zorder=2) | |
ax.scatter(x, y, s=8, color='black', zorder=3) | |
# add connecting line | |
ax.plot(x, y, color='black', zorder=1, linewidth=0.7) | |
# add horizontal dotted lines. See linestyles here: https://matplotlib.org/3.1.0/gallery/lines_bars_and_markers/linestyles.html | |
ax.plot([1970, 1977], [380, 380], linestyle=( |
View tufte3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib.ticker import FuncFormatter | |
from matplotlib.patches import ArrowStyle | |
fig, ax = plt.subplots(figsize=(7, 3)) | |
# remove splines | |
for spine in ax.spines.keys(): | |
ax.spines[spine].set_visible(False) | |
# set axis limits |
View tufte2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = list(range(1967,1978)) | |
y = [310, 330, 370, 385, 385, 393, 387, 380, 390, 400, 380] |
View tufte1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib as plt | |
plt.rcParams['font.family'] = 'serif' | |
plt.rcParams['font.serif'] = 'Sabon RomanOsF' |