Skip to content

Commit 75c449e

Browse files
authored
1 parent 836773e commit 75c449e

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1-without-liberation-fonts/*
2+
2-with-liberation-fonts/*
3+
4+
!.keep

1-without-liberation-fonts/.keep

Whitespace-only changes.

2-with-liberation-fonts/.keep

Whitespace-only changes.

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
setup:
2+
pip install mplfinance pyarrow # install pyarrow only to get rid of pandas warning
3+
4+
test:
5+
sudo apt remove -y fonts-liberation
6+
rm -f ~/.cache/matplotlib/fontlist-v330.json
7+
FILE=1-without-liberation-fonts/image.png python script.py 2> 1-without-liberation-fonts/mpl-debug-logs.txt
8+
9+
sudo apt update
10+
sudo apt install fonts-liberation
11+
rm -f ~/.cache/matplotlib/fontlist-v330.json
12+
FILE=2-with-liberation-fonts/image.png python script.py 2> 2-with-liberation-fonts/mpl-debug-logs.txt
13+
14+
echo && md5sum 1-without-liberation-fonts/image.png 2-with-liberation-fonts/image.png && echo
15+
echo && tail -n 1 1-without-liberation-fonts/mpl-debug-logs.txt 2-with-liberation-fonts/mpl-debug-logs.txt

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
# mplfinance
2-
For matplotlib/mplfinance#661
1+
1. Run `make setup` - installs the latest `mplfinance`
2+
3+
2. Run `make test`:
4+
5+
- remove fonts-liberation if installed
6+
- renders the simplest chart
7+
- installs fonts-liberation
8+
- renders the chart again
9+
- prints MD5 sums of the images
10+
- prints the last lines of the `matplotlib` debug logs

script.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
3+
import matplotlib.pyplot as plt
4+
import pandas as pd
5+
6+
import mplfinance as mpf
7+
8+
plt.set_loglevel("debug")
9+
10+
window = pd.DataFrame(
11+
[
12+
[2.00, 4.00, 1.00, 3.00],
13+
],
14+
columns=["open", "high", "low", "close"],
15+
)
16+
17+
window.index = pd.date_range("2022-01-01", periods=len(window), freq="D")
18+
19+
mpf.plot(window, type="candle", savefig=os.environ["FILE"])

0 commit comments

Comments
 (0)