Skip to content

Commit e8d8aee

Browse files
add comments to animation demos
1 parent fd56a6a commit e8d8aee

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

examples/external_axes.ipynb

Lines changed: 13 additions & 11 deletions
Large diffs are not rendered by default.

examples/mpf_animation_demo1.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
'''
2+
This file contains a simple animation demo using mplfinance "external axes mode".
3+
4+
Note that presently mplfinance does not support "blitting" (blitting makes animation
5+
more efficient). Nonetheless, the animation is efficient enough to update at least
6+
once per second, and typically more frequently depending on the size of the plot.
7+
'''
18
import pandas as pd
29
import mplfinance as mpf
310
import matplotlib.animation as animation

examples/mpf_animation_demo2.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
'''
2+
This file contains a simple animation demo using mplfinance "external axes mode".
3+
4+
In this example, instead of creating the Figure and Axes external to mplfiance,
5+
we allow mplfinance to create the Figure and Axes using its "panel method", and
6+
set kwarg `returnfig=True` so that mplfinance will return the Figure and Axes.
7+
8+
We then take those Axes and pass them back into mplfinance ("external axes mode")
9+
as part of the animation.
10+
11+
Note that presently mplfinance does not support "blitting" (blitting makes animation
12+
more efficient). Nonetheless, the animation is efficient enough to update at least
13+
once per second, and typically more frequently depending on the size of the plot.
14+
'''
115
import pandas as pd
216
import mplfinance as mpf
317
import matplotlib.animation as animation
@@ -8,7 +22,9 @@
822

923
pkwargs=dict(type='candle',mav=(10,20))
1024

11-
fig, axes = mpf.plot(df.iloc[0:20],returnfig=True,volume=True,figsize=(11,8),panel_ratios=(2,1),title='\n\nS&P 500 ETF',**pkwargs)
25+
fig, axes = mpf.plot(df.iloc[0:20],returnfig=True,volume=True,
26+
figsize=(11,8),panel_ratios=(2,1),
27+
title='\n\nS&P 500 ETF',**pkwargs)
1228
ax1 = axes[0]
1329
ax2 = axes[2]
1430

examples/mpf_animation_macd.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
'''
2+
This file contains a animation demo using mplfinance "external axes mode",
3+
in which animate both the display of candlesticks as well as the display
4+
of MACD (Moving Average Convergence Divergence) visual analysis.
5+
6+
In this example, instead of creating the Figure and Axes external to mplfiance,
7+
we allow mplfinance to create the Figure and Axes using its "panel method", and
8+
set kwarg `returnfig=True` so that mplfinance will return the Figure and Axes.
9+
10+
We then take those Axes and pass them back into mplfinance ("external axes mode")
11+
as part of the animation.
12+
13+
Note that presently mplfinance does not support "blitting" (blitting makes animation
14+
more efficient). Nonetheless, the animation is efficient enough to update at least
15+
once per second, and typically more frequently depending on the size of the plot.
16+
'''
117
import pandas as pd
218
import mplfinance as mpf
319
import matplotlib.animation as animation

0 commit comments

Comments
 (0)