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

Skip to content

Commit bebdae0

Browse files
authored
Merge pull request matplotlib#57 from jimustafa/master
add workflow for building artifacts
2 parents 92d26b5 + d074da7 commit bebdae0

26 files changed

+334
-52
lines changed

.github/workflows/main.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,45 @@ jobs:
99
- uses: actions/checkout@v2
1010
- uses: actions/setup-python@v2
1111
- uses: pre-commit/[email protected]
12+
build:
13+
runs-on: ubuntu-20.04
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-python@v2
17+
with:
18+
python-version: 3.6
19+
- name: Install dependencies
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install \
23+
fontconfig \
24+
libgeos++-dev \
25+
libproj-dev
26+
python -m pip install --upgrade pip
27+
pip install -r requirements/requirements-base.txt
28+
pip install -r requirements/requirements.txt
29+
- name: Install Tex Live
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install \
33+
texlive-base \
34+
texlive-extra-utils \
35+
texlive-fonts-extra \
36+
texlive-fonts-recommended \
37+
texlive-latex-base \
38+
texlive-latex-extra \
39+
texlive-latex-recommended \
40+
texlive-xetex
41+
- name: Build artifacts
42+
run: |
43+
rm *.pdf
44+
make -C fonts/
45+
cp -r fonts/ /usr/share/fonts/
46+
fc-cache
47+
make figures cheatsheets handouts
48+
- uses: actions/upload-artifact@v2
49+
with:
50+
name: build
51+
path: |
52+
cheatsheets.pdf
53+
handout-*.pdf

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
fonts/*
2-
*.upa
1+
*.aux
32
*.log
43
*.out
5-
*.aux
4+
*.upa
65
figures/*.pdf
6+
fonts/**/*.[ot]tf

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
SRC := $(wildcard *.tex)
2+
3+
.PHONY: default
4+
default: all
5+
6+
.PHONY: all
7+
all: figures cheatsheets
8+
9+
.PHONY: figures
10+
figures:
11+
# generate the figures
12+
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
17+
18+
.PHONY: cheatsheets
19+
cheatsheets:
20+
xelatex cheatsheets.tex
21+
22+
.PHONY: handouts
23+
handouts:
24+
xelatex handout-beginner.tex
25+
xelatex handout-intermediate.tex
26+
xelatex handout-tips.tex
27+
28+
.PHONY: fonts
29+
fonts:
30+
make -C fonts/
31+
32+
.PHONY: clean
33+
clean: $(SRC)
34+
git clean -f -X ./figures/
35+
git clean -f ./scripts/*.pdf
36+
latexmk -c $^
37+
38+
.PHONY: requirements
39+
requirements:
40+
$(MAKE) -C ./requirements/

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,21 @@
2828
or https://github.com/adobe-fonts/source-serif-pro/tree/release/OTF
2929
* `fonts/delicious-123/*` : See https://www.exljbris.com/delicious.html
3030

31+
On Linux, with `make` installed, the fonts can be set up with the following command:
32+
```shell
33+
make -C fonts
34+
```
3135

36+
The fonts can be made discoverable by `matplotlib` (through `fontconfig`) by creating the following in `$HOME/.config/fontconfig/fonts.conf` (see [here](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html)):
3237

38+
```xml
39+
<?xml version="1.0"?>
40+
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
41+
<fontconfig>
42+
<dir>/path/to/cheatsheets/fonts/</dir>
43+
...
44+
</fontconfig>
45+
```
3346

3447

3548
2. You need to generate all the figures:

fonts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.uuid

fonts/Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FONT_DIRS := delicious-123 roboto roboto-mono roboto-slab source-code-pro source-sans-pro source-serif-pro
2+
3+
DELICIOUS_ZIP := http://www.exljbris.com/dl/DELICIOUS_21_OTF.zip
4+
ROBOTO_ZIP := https://github.com/googlefonts/roboto/releases/download/v2.138/roboto-unhinted.zip
5+
ROBOTO_MONO_ZIP := https://github.com/googlefonts/RobotoMono/archive/8f651634e746da6df6c2c0be73255721d24f2372.zip
6+
ROBOTO_SLAB_ZIP := https://github.com/googlefonts/robotoslab/archive/a65e6d00d8e3e7ee2fabef844e58fa12690384d2.zip
7+
SOURCE_CODE_PRO_ZIP := https://github.com/adobe-fonts/source-code-pro/releases/download/2.038R-ro%2F1.058R-it%2F1.018R-VAR/OTF-source-code-pro-2.038R-ro-1.058R-it.zip
8+
SOURCE_SANS_PRO_ZIP := https://github.com/adobe-fonts/source-sans/releases/download/2.045R-ro%2F1.095R-it/source-sans-pro-2.045R-ro-1.095R-it.zip
9+
SOURCE_SERIF_PRO_ZIP := https://github.com/adobe-fonts/source-serif/releases/download/3.001R/source-serif-pro-3.001R.zip
10+
11+
UNZIP_FLAGS := -x "__MACOSX/*"
12+
13+
14+
.PHONY: default
15+
default: all
16+
17+
.PHONY: all
18+
all: sources
19+
mkdir -p $(FONT_DIRS)
20+
cd delicious-123 && unzip -j /tmp/delicious.zip "DELICIOUS_21_OTF/*.otf" $(UNZIP_FLAGS)
21+
cd delicious-123 && ln -sf Delicious_R_2021.otf Delicious-Roman.otf
22+
cd delicious-123 && ln -sf Delicious_SC_2021.otf Delicious-SmallCaps.otf
23+
cd roboto && unzip -j /tmp/roboto.zip "*.ttf" $(UNZIP_FLAGS)
24+
cd roboto-mono && unzip -j /tmp/roboto-mono.zip "RobotoMono-8f651634e746da6df6c2c0be73255721d24f2372/fonts/ttf/*.ttf" $(UNZIP_FLAGS)
25+
cd roboto-slab && unzip -j /tmp/roboto-slab.zip "robotoslab-a65e6d00d8e3e7ee2fabef844e58fa12690384d2/fonts/static/*.ttf" $(UNZIP_FLAGS)
26+
cd source-code-pro && unzip -j /tmp/source-code-pro.zip "*.otf" $(UNZIP_FLAGS)
27+
cd source-sans-pro && unzip -j /tmp/source-sans-pro.zip "source-sans-pro-2.045R-ro-1.095R-it/OTF/*.otf" $(UNZIP_FLAGS)
28+
cd source-serif-pro && unzip -j /tmp/source-serif-pro.zip "source-serif-pro-3.001R/OTF/*.otf" $(UNZIP_FLAGS)
29+
30+
.PHONY: sources
31+
sources:
32+
wget $(DELICIOUS_ZIP) -O /tmp/delicious.zip
33+
wget $(ROBOTO_ZIP) -O /tmp/roboto.zip
34+
wget $(ROBOTO_MONO_ZIP) -O /tmp/roboto-mono.zip
35+
wget $(ROBOTO_SLAB_ZIP) -O /tmp/roboto-slab.zip
36+
wget $(SOURCE_CODE_PRO_ZIP) -O /tmp/source-code-pro.zip
37+
wget $(SOURCE_SANS_PRO_ZIP) -O /tmp/source-sans-pro.zip
38+
wget $(SOURCE_SERIF_PRO_ZIP) -O /tmp/source-serif-pro.zip
39+
40+
.PHONY: clean
41+
clean:
42+
- rm $(HOME)/.cache/matplotlib/fontlist*
43+
- rm -rf $(FONT_DIRS)

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)

requirements/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.PHONY: default
2+
default: all
3+
4+
.PHONY: all
5+
all: requirements-base.txt requirements.txt
6+
7+
.PHONY: install
8+
install: requirements-base.txt requirements.txt
9+
pip-sync $^
10+
11+
requirements.txt: requirements-base.txt
12+
13+
%.txt: %.in
14+
pip-compile $<

requirements/requirements-base.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy
2+
pip-tools

requirements/requirements-base.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# This file is autogenerated by pip-compile
3+
# To update, run:
4+
#
5+
# pip-compile requirements-base.in
6+
#
7+
click==7.1.2
8+
# via pip-tools
9+
importlib-metadata==3.9.0
10+
# via pep517
11+
numpy==1.19.5
12+
# via -r requirements-base.in
13+
pep517==0.10.0
14+
# via pip-tools
15+
pip-tools==6.0.1
16+
# via -r requirements-base.in
17+
toml==0.10.2
18+
# via pep517
19+
typing-extensions==3.7.4.3
20+
# via importlib-metadata
21+
zipp==3.4.1
22+
# via
23+
# importlib-metadata
24+
# pep517
25+
26+
# The following packages are considered to be unsafe in a requirements file:
27+
# pip

requirements/requirements.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-c ./requirements-base.txt
2+
3+
cartopy
4+
fonttools[woff]
5+
matplotlib
6+
pre-commit
7+
scipy
8+
9+
--no-binary shapely

requirements/requirements.txt

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#
2+
# This file is autogenerated by pip-compile
3+
# To update, run:
4+
#
5+
# pip-compile requirements.in
6+
#
7+
--no-binary shapely
8+
9+
appdirs==1.4.4
10+
# via virtualenv
11+
brotli==1.0.9
12+
# via fonttools
13+
cartopy==0.18.0
14+
# via -r requirements.in
15+
cfgv==3.2.0
16+
# via pre-commit
17+
cycler==0.10.0
18+
# via matplotlib
19+
distlib==0.3.1
20+
# via virtualenv
21+
filelock==3.0.12
22+
# via virtualenv
23+
fonttools[woff]==4.21.1
24+
# via -r requirements.in
25+
identify==2.2.2
26+
# via pre-commit
27+
importlib-metadata==3.9.0
28+
# via
29+
# -c ./requirements-base.txt
30+
# pre-commit
31+
# virtualenv
32+
importlib-resources==5.1.2
33+
# via
34+
# pre-commit
35+
# virtualenv
36+
kiwisolver==1.3.1
37+
# via matplotlib
38+
matplotlib==3.3.4
39+
# via -r requirements.in
40+
nodeenv==1.5.0
41+
# via pre-commit
42+
numpy==1.19.5
43+
# via
44+
# -c ./requirements-base.txt
45+
# cartopy
46+
# matplotlib
47+
# scipy
48+
pillow==8.1.2
49+
# via matplotlib
50+
pre-commit==2.11.1
51+
# via -r requirements.in
52+
pyparsing==2.4.7
53+
# via matplotlib
54+
pyshp==2.1.3
55+
# via cartopy
56+
python-dateutil==2.8.1
57+
# via matplotlib
58+
pyyaml==5.4.1
59+
# via pre-commit
60+
scipy==1.5.4
61+
# via -r requirements.in
62+
shapely==1.7.1
63+
# via cartopy
64+
six==1.15.0
65+
# via
66+
# cartopy
67+
# cycler
68+
# python-dateutil
69+
# virtualenv
70+
toml==0.10.2
71+
# via
72+
# -c ./requirements-base.txt
73+
# pre-commit
74+
typing-extensions==3.7.4.3
75+
# via
76+
# -c ./requirements-base.txt
77+
# importlib-metadata
78+
virtualenv==20.4.3
79+
# via pre-commit
80+
zipp==3.4.1
81+
# via
82+
# -c ./requirements-base.txt
83+
# importlib-metadata
84+
# importlib-resources
85+
zopfli==0.1.8
86+
# via fonttools
87+
88+
# The following packages are considered to be unsafe in a requirements file:
89+
# setuptools

scripts/anatomy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,4 @@ def text(x, y, text):
136136
color=color))
137137

138138
plt.savefig("../figures/anatomy.pdf")
139-
plt.show()
139+
# plt.show()

scripts/animation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ def animate(i):
99
line.set_ydata(np.sin(T+i/50))
1010
a=animation.FuncAnimation(
1111
plt.gcf(), animate, interval=5)
12-
plt.show()
12+
# plt.show()

scripts/extents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@
6363

6464

6565
plt.savefig("../figures/extents.pdf", dpi=600)
66-
plt.show()
66+
# plt.show()

scripts/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,4 @@ def int_arrow(p0,p1):
125125
rotation = "vertical", ha="center", va="center", size="x-small")
126126

127127
plt.savefig("figure.pdf")
128-
plt.show()
128+
# plt.show()

scripts/interpolations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919

2020
plt.tight_layout()
2121
plt.savefig("../figures/interpolations.pdf", dpi=600)
22-
plt.show()
22+
# plt.show()

scripts/line.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ def split(n_segment):
8282
y -= 1
8383

8484
plt.savefig("line.pdf", dpi=200)
85-
plt.show()
85+
# plt.show()

0 commit comments

Comments
 (0)