Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d074da7

Browse files
committed
update and build handouts
1 parent f75ea6b commit d074da7

File tree

5 files changed

+51
-42
lines changed

5 files changed

+51
-42
lines changed

.github/workflows/main.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ jobs:
3131
sudo apt-get update
3232
sudo apt-get install \
3333
texlive-base \
34+
texlive-extra-utils \
35+
texlive-fonts-extra \
36+
texlive-fonts-recommended \
3437
texlive-latex-base \
3538
texlive-latex-extra \
3639
texlive-latex-recommended \
37-
texlive-fonts-recommended \
3840
texlive-xetex
3941
- name: Build artifacts
4042
run: |
4143
rm *.pdf
4244
make -C fonts/
4345
cp -r fonts/ /usr/share/fonts/
4446
fc-cache
45-
make figures cheatsheets
47+
make figures cheatsheets handouts
4648
- uses: actions/upload-artifact@v2
4749
with:
4850
name: build

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ all: figures cheatsheets
88

99
.PHONY: figures
1010
figures:
11+
# generate the figures
1112
cd scripts && for script in *.py; do echo $$script; python $$script; done
13+
# crop the figures
14+
cd figures && for figure in *.pdf; do echo $$figure; pdfcrop $$figure $$figure; done
15+
# regenerate some figures that should not be cropped
16+
cd scripts && python styles.py
1217

1318
.PHONY: cheatsheets
1419
cheatsheets:
1520
xelatex cheatsheets.tex
1621

1722
.PHONY: handouts
1823
handouts:
19-
# xelatex handout-beginner.tex
20-
# xelatex handout-intermediate.tex
24+
xelatex handout-beginner.tex
25+
xelatex handout-intermediate.tex
2126
xelatex handout-tips.tex
2227

2328
.PHONY: fonts
@@ -26,7 +31,7 @@ fonts:
2631

2732
.PHONY: clean
2833
clean: $(SRC)
29-
git clean -f ./figures/
34+
git clean -f -X ./figures/
3035
git clean -f ./scripts/*.pdf
3136
latexmk -c $^
3237

handout-intermediate.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ \section*{\LARGE \rmfamily
7676
A matplotlib figure is composed of a hierarchy of elements that forms
7777
the actual figure. Each element can be modified. \medskip
7878

79-
\includegraphics[width=\linewidth]{anatomy-cropped.pdf}
79+
\includegraphics[width=\linewidth]{anatomy.pdf}
8080

8181
\subsection*{\rmfamily Figure, axes \& spines}
8282

handout-tips.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ \subsection*{\rmfamily Offline rendering}
121121

122122
% -----------------------------------------------------------------------------
123123
\subsection*{\rmfamily Range of continuous colors}
124+
124125
You can use colormap to pick from a range of continuous colors.
126+
125127
\begin{tabular}{@{}m{.774\linewidth}m{.216\linewidth}}
126128
\begin{lstlisting}[belowskip=-\baselineskip]
127129
X = np.random.randn(1000, 4)

scripts/sine.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,50 @@
88
X = np.linspace(0.1, 10*np.pi, 10000)
99
Y = np.sin(X)
1010

11-
# fig = plt.figure(figsize=(8,2))
12-
# plt.plot(X, Y, color="orange", linewidth=2)
11+
fig = plt.figure(figsize=(8,2))
12+
plt.plot(X, Y, color="orange", linewidth=2)
1313
# plt.xticks([]), plt.yticks([])
14-
# plt.tight_layout()
15-
# plt.savefig("../figures/sine.pdf", dpi=100)
14+
plt.tight_layout()
15+
plt.savefig("../figures/sine.pdf", dpi=100)
1616

17-
# fig = plt.figure(figsize=(7,1.5))
18-
# plt.plot(X, Y, "C1o:", markevery=500, mec="1.0", lw=2, ms=8.5, mew=2)
19-
# # plt.xticks([]), plt.yticks([])
20-
# plt.ylim(-1.5, 1.5)
21-
# plt.tight_layout()
22-
# plt.savefig("../figures/sine-marker.pdf", dpi=100)
17+
fig = plt.figure(figsize=(7,1.5))
18+
plt.plot(X, Y, "C1o:", markevery=500, mec="1.0", lw=2, ms=8.5, mew=2)
19+
# plt.xticks([]), plt.yticks([])
20+
plt.ylim(-1.5, 1.5)
21+
plt.tight_layout()
22+
plt.savefig("../figures/sine-marker.pdf", dpi=100)
2323

24-
# fig, ax = plt.subplots(figsize=(7,1.5))
25-
# ax.set_xscale("log")
26-
# ax.plot(X, Y, "-")
27-
# plt.plot(X, Y, "C1o-", markevery=500, mec="1.0", lw=2, ms=8.5, mew=2)
28-
# #plt.xticks([]), plt.yticks([])
29-
# plt.ylim(-1.5, 1.5)
30-
# plt.tight_layout()
31-
# plt.savefig("../figures/sine-logscale.pdf", dpi=100)
24+
fig, ax = plt.subplots(figsize=(7,1.5))
25+
ax.set_xscale("log")
26+
ax.plot(X, Y, "-")
27+
plt.plot(X, Y, "C1o-", markevery=500, mec="1.0", lw=2, ms=8.5, mew=2)
28+
#plt.xticks([]), plt.yticks([])
29+
plt.ylim(-1.5, 1.5)
30+
plt.tight_layout()
31+
plt.savefig("../figures/sine-logscale.pdf", dpi=100)
3232

3333

34-
# fig = plt.figure(figsize=(7,1.5))
35-
# plt.plot(X, Y, "C1", lw=2)
36-
# plt.fill_betweenx([-1.5,1.5],[0],[2*np.pi], color=".9")
37-
# plt.text(0, -1, r" Period $\Phi$")
38-
# # plt.xticks([]), plt.yticks([])
39-
# plt.ylim(-1.5, 1.5)
40-
# plt.tight_layout()
41-
# plt.savefig("../figures/sine-period.pdf", dpi=100)
34+
fig = plt.figure(figsize=(7,1.5))
35+
plt.plot(X, Y, "C1", lw=2)
36+
plt.fill_betweenx([-1.5,1.5],[0],[2*np.pi], color=".9")
37+
plt.text(0, -1, r" Period $\Phi$")
38+
# plt.xticks([]), plt.yticks([])
39+
plt.ylim(-1.5, 1.5)
40+
plt.tight_layout()
41+
plt.savefig("../figures/sine-period.pdf", dpi=100)
4242
# plt.show()
4343

4444

45-
# fig = plt.figure(figsize=(7,1.5))
46-
# plt.plot(X, np.sin(X), "C0", lw=2, label="Sine")
47-
# plt.plot(X, np.cos(X), "C1", lw=2, label="Cosine")
48-
# plt.legend(bbox_to_anchor = (0.0, .9, 1.02, 0.1),
49-
# frameon=False, mode="expand", ncol=2, loc="lower left")
50-
# plt.title("Sine and Cosine")
51-
# plt.xticks([]), plt.yticks([])
52-
# plt.ylim(-1.25, 1.25)
53-
# plt.tight_layout()
54-
# plt.savefig("../figures/sine-legend.pdf", dpi=100)
45+
fig = plt.figure(figsize=(7,1.5))
46+
plt.plot(X, np.sin(X), "C0", lw=2, label="Sine")
47+
plt.plot(X, np.cos(X), "C1", lw=2, label="Cosine")
48+
plt.legend(bbox_to_anchor = (0.0, .9, 1.02, 0.1),
49+
frameon=False, mode="expand", ncol=2, loc="lower left")
50+
plt.title("Sine and Cosine")
51+
plt.xticks([]), plt.yticks([])
52+
plt.ylim(-1.25, 1.25)
53+
plt.tight_layout()
54+
plt.savefig("../figures/sine-legend.pdf", dpi=100)
5555
# plt.show()
5656

5757

0 commit comments

Comments
 (0)