Skip to content

Commit

Permalink
Playground for matplotlib/mplfinance#661
Browse files Browse the repository at this point in the history
  • Loading branch information
GarrisonD committed Feb 25, 2024
1 parent 836773e commit 75c449e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1-without-liberation-fonts/*
2-with-liberation-fonts/*

!.keep
Empty file.
Empty file added 2-with-liberation-fonts/.keep
Empty file.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
setup:
pip install mplfinance pyarrow # install pyarrow only to get rid of pandas warning

test:
sudo apt remove -y fonts-liberation
rm -f ~/.cache/matplotlib/fontlist-v330.json
FILE=1-without-liberation-fonts/image.png python script.py 2> 1-without-liberation-fonts/mpl-debug-logs.txt

sudo apt update
sudo apt install fonts-liberation
rm -f ~/.cache/matplotlib/fontlist-v330.json
FILE=2-with-liberation-fonts/image.png python script.py 2> 2-with-liberation-fonts/mpl-debug-logs.txt

echo && md5sum 1-without-liberation-fonts/image.png 2-with-liberation-fonts/image.png && echo
echo && tail -n 1 1-without-liberation-fonts/mpl-debug-logs.txt 2-with-liberation-fonts/mpl-debug-logs.txt
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# mplfinance
For matplotlib/mplfinance#661
1. Run `make setup` - installs the latest `mplfinance`

2. Run `make test`:

- remove fonts-liberation if installed
- renders the simplest chart
- installs fonts-liberation
- renders the chart again
- prints MD5 sums of the images
- prints the last lines of the `matplotlib` debug logs
19 changes: 19 additions & 0 deletions script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os

import matplotlib.pyplot as plt
import pandas as pd

import mplfinance as mpf

plt.set_loglevel("debug")

window = pd.DataFrame(
[
[2.00, 4.00, 1.00, 3.00],
],
columns=["open", "high", "low", "close"],
)

window.index = pd.date_range("2022-01-01", periods=len(window), freq="D")

mpf.plot(window, type="candle", savefig=os.environ["FILE"])

0 comments on commit 75c449e

Please sign in to comment.