Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,45 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.0
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install \
fontconfig \
libgeos++-dev \
libproj-dev
python -m pip install --upgrade pip
pip install -r requirements/requirements-base.txt
pip install -r requirements/requirements.txt
- name: Install Tex Live
run: |
sudo apt-get update
sudo apt-get install \
texlive-base \
texlive-extra-utils \
texlive-fonts-extra \
texlive-fonts-recommended \
texlive-latex-base \
texlive-latex-extra \
texlive-latex-recommended \
texlive-xetex
- name: Build artifacts
run: |
rm *.pdf
make -C fonts/
cp -r fonts/ /usr/share/fonts/
fc-cache
make figures cheatsheets handouts
- uses: actions/upload-artifact@v2
with:
name: build
path: |
cheatsheets.pdf
handout-*.pdf
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fonts/*
*.upa
*.aux
*.log
*.out
*.aux
*.upa
figures/*.pdf
fonts/**/*.[ot]tf
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
SRC := $(wildcard *.tex)

.PHONY: default
default: all

.PHONY: all
all: figures cheatsheets

.PHONY: figures
figures:
# generate the figures
cd scripts && for script in *.py; do echo $$script; python $$script; done
# crop the figures
cd figures && for figure in *.pdf; do echo $$figure; pdfcrop $$figure $$figure; done
# regenerate some figures that should not be cropped
cd scripts && python styles.py

.PHONY: cheatsheets
cheatsheets:
xelatex cheatsheets.tex

.PHONY: handouts
handouts:
xelatex handout-beginner.tex
xelatex handout-intermediate.tex
xelatex handout-tips.tex

.PHONY: fonts
fonts:
make -C fonts/

.PHONY: clean
clean: $(SRC)
git clean -f -X ./figures/
git clean -f ./scripts/*.pdf
latexmk -c $^

.PHONY: requirements
requirements:
$(MAKE) -C ./requirements/
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,21 @@
or https://github.com/adobe-fonts/source-serif-pro/tree/release/OTF
* `fonts/delicious-123/*` : See https://www.exljbris.com/delicious.html

On Linux, with `make` installed, the fonts can be set up with the following command:
```shell
make -C fonts
```

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)):

```xml
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/path/to/cheatsheets/fonts/</dir>
...
</fontconfig>
```


2. You need to generate all the figures:
Expand Down
1 change: 1 addition & 0 deletions fonts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.uuid
43 changes: 43 additions & 0 deletions fonts/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FONT_DIRS := delicious-123 roboto roboto-mono roboto-slab source-code-pro source-sans-pro source-serif-pro

DELICIOUS_ZIP := http://www.exljbris.com/dl/DELICIOUS_21_OTF.zip
ROBOTO_ZIP := https://github.com/googlefonts/roboto/releases/download/v2.138/roboto-unhinted.zip
ROBOTO_MONO_ZIP := https://github.com/googlefonts/RobotoMono/archive/8f651634e746da6df6c2c0be73255721d24f2372.zip
ROBOTO_SLAB_ZIP := https://github.com/googlefonts/robotoslab/archive/a65e6d00d8e3e7ee2fabef844e58fa12690384d2.zip
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
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
SOURCE_SERIF_PRO_ZIP := https://github.com/adobe-fonts/source-serif/releases/download/3.001R/source-serif-pro-3.001R.zip

UNZIP_FLAGS := -x "__MACOSX/*"


.PHONY: default
default: all

.PHONY: all
all: sources
mkdir -p $(FONT_DIRS)
cd delicious-123 && unzip -j /tmp/delicious.zip "DELICIOUS_21_OTF/*.otf" $(UNZIP_FLAGS)
cd delicious-123 && ln -sf Delicious_R_2021.otf Delicious-Roman.otf
cd delicious-123 && ln -sf Delicious_SC_2021.otf Delicious-SmallCaps.otf
cd roboto && unzip -j /tmp/roboto.zip "*.ttf" $(UNZIP_FLAGS)
cd roboto-mono && unzip -j /tmp/roboto-mono.zip "RobotoMono-8f651634e746da6df6c2c0be73255721d24f2372/fonts/ttf/*.ttf" $(UNZIP_FLAGS)
cd roboto-slab && unzip -j /tmp/roboto-slab.zip "robotoslab-a65e6d00d8e3e7ee2fabef844e58fa12690384d2/fonts/static/*.ttf" $(UNZIP_FLAGS)
cd source-code-pro && unzip -j /tmp/source-code-pro.zip "*.otf" $(UNZIP_FLAGS)
cd source-sans-pro && unzip -j /tmp/source-sans-pro.zip "source-sans-pro-2.045R-ro-1.095R-it/OTF/*.otf" $(UNZIP_FLAGS)
cd source-serif-pro && unzip -j /tmp/source-serif-pro.zip "source-serif-pro-3.001R/OTF/*.otf" $(UNZIP_FLAGS)

.PHONY: sources
sources:
wget $(DELICIOUS_ZIP) -O /tmp/delicious.zip
wget $(ROBOTO_ZIP) -O /tmp/roboto.zip
wget $(ROBOTO_MONO_ZIP) -O /tmp/roboto-mono.zip
wget $(ROBOTO_SLAB_ZIP) -O /tmp/roboto-slab.zip
wget $(SOURCE_CODE_PRO_ZIP) -O /tmp/source-code-pro.zip
wget $(SOURCE_SANS_PRO_ZIP) -O /tmp/source-sans-pro.zip
wget $(SOURCE_SERIF_PRO_ZIP) -O /tmp/source-serif-pro.zip

.PHONY: clean
clean:
- rm $(HOME)/.cache/matplotlib/fontlist*
- rm -rf $(FONT_DIRS)
2 changes: 1 addition & 1 deletion handout-intermediate.tex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ \section*{\LARGE \rmfamily
A matplotlib figure is composed of a hierarchy of elements that forms
the actual figure. Each element can be modified. \medskip

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

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

Expand Down
2 changes: 2 additions & 0 deletions handout-tips.tex
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ \subsection*{\rmfamily Offline rendering}

% -----------------------------------------------------------------------------
\subsection*{\rmfamily Range of continuous colors}

You can use colormap to pick from a range of continuous colors.

\begin{tabular}{@{}m{.774\linewidth}m{.216\linewidth}}
\begin{lstlisting}[belowskip=-\baselineskip]
X = np.random.randn(1000, 4)
Expand Down
14 changes: 14 additions & 0 deletions requirements/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.PHONY: default
default: all

.PHONY: all
all: requirements-base.txt requirements.txt

.PHONY: install
install: requirements-base.txt requirements.txt
pip-sync $^

requirements.txt: requirements-base.txt

%.txt: %.in
pip-compile $<
2 changes: 2 additions & 0 deletions requirements/requirements-base.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy
pip-tools
27 changes: 27 additions & 0 deletions requirements/requirements-base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements-base.in
#
click==7.1.2
# via pip-tools
importlib-metadata==3.9.0
# via pep517
numpy==1.19.5
# via -r requirements-base.in
pep517==0.10.0
# via pip-tools
pip-tools==6.0.1
# via -r requirements-base.in
toml==0.10.2
# via pep517
typing-extensions==3.7.4.3
# via importlib-metadata
zipp==3.4.1
# via
# importlib-metadata
# pep517

# The following packages are considered to be unsafe in a requirements file:
# pip
9 changes: 9 additions & 0 deletions requirements/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-c ./requirements-base.txt

cartopy
fonttools[woff]
matplotlib
pre-commit
scipy

--no-binary shapely
89 changes: 89 additions & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile requirements.in
#
--no-binary shapely

appdirs==1.4.4
# via virtualenv
brotli==1.0.9
# via fonttools
cartopy==0.18.0
# via -r requirements.in
cfgv==3.2.0
# via pre-commit
cycler==0.10.0
# via matplotlib
distlib==0.3.1
# via virtualenv
filelock==3.0.12
# via virtualenv
fonttools[woff]==4.21.1
# via -r requirements.in
identify==2.2.2
# via pre-commit
importlib-metadata==3.9.0
# via
# -c ./requirements-base.txt
# pre-commit
# virtualenv
importlib-resources==5.1.2
# via
# pre-commit
# virtualenv
kiwisolver==1.3.1
# via matplotlib
matplotlib==3.3.4
# via -r requirements.in
nodeenv==1.5.0
# via pre-commit
numpy==1.19.5
# via
# -c ./requirements-base.txt
# cartopy
# matplotlib
# scipy
pillow==8.1.2
# via matplotlib
pre-commit==2.11.1
# via -r requirements.in
pyparsing==2.4.7
# via matplotlib
pyshp==2.1.3
# via cartopy
python-dateutil==2.8.1
# via matplotlib
pyyaml==5.4.1
# via pre-commit
scipy==1.5.4
# via -r requirements.in
shapely==1.7.1
# via cartopy
six==1.15.0
# via
# cartopy
# cycler
# python-dateutil
# virtualenv
toml==0.10.2
# via
# -c ./requirements-base.txt
# pre-commit
typing-extensions==3.7.4.3
# via
# -c ./requirements-base.txt
# importlib-metadata
virtualenv==20.4.3
# via pre-commit
zipp==3.4.1
# via
# -c ./requirements-base.txt
# importlib-metadata
# importlib-resources
zopfli==0.1.8
# via fonttools

# The following packages are considered to be unsafe in a requirements file:
# setuptools
2 changes: 1 addition & 1 deletion scripts/anatomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ def text(x, y, text):
color=color))

plt.savefig("../figures/anatomy.pdf")
plt.show()
# plt.show()
2 changes: 1 addition & 1 deletion scripts/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def animate(i):
line.set_ydata(np.sin(T+i/50))
a=animation.FuncAnimation(
plt.gcf(), animate, interval=5)
plt.show()
# plt.show()
2 changes: 1 addition & 1 deletion scripts/extents.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@


plt.savefig("../figures/extents.pdf", dpi=600)
plt.show()
# plt.show()
2 changes: 1 addition & 1 deletion scripts/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ def int_arrow(p0,p1):
rotation = "vertical", ha="center", va="center", size="x-small")

plt.savefig("figure.pdf")
plt.show()
# plt.show()
2 changes: 1 addition & 1 deletion scripts/interpolations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

plt.tight_layout()
plt.savefig("../figures/interpolations.pdf", dpi=600)
plt.show()
# plt.show()
2 changes: 1 addition & 1 deletion scripts/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ def split(n_segment):
y -= 1

plt.savefig("line.pdf", dpi=200)
plt.show()
# plt.show()
Loading