Skip to content

Commit 511a639

Browse files
Update subplots.md
1 parent e544a04 commit 511a639

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

markdown/animation.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Animation Support in mplfinance
2+
3+
* [**External Axes Mode**](https://github.com/matplotlib/mplfinance/blob/master/markdown/subplots.md#external-axes-method) of mplfinance allows them user to create and manage their own Figure and Axes (SubPlots), and pass Axes into mplfinance. This automatically gives users access to matplotlib's animation features.
4+
* It can be tricky to get animations to display properly in jupyter notebooks,<br>&nbsp; so to keep things simple, the mplfinance animation examples are indpendent scripts.
5+
* To run the animation examples, clone this repository, then **`cd`** into the **`mplfinance/examples`** folder, and run:
6+
- [**`python mpf_animation_demo1.py`**](https://github.com/matplotlib/mplfinance/blob/master/examples/mpf_animation_demo1.py)
7+
- [**`python mpf_animation_demo2.py`**](https://github.com/matplotlib/mplfinance/blob/master/examples/mpf_animation_demo2.py)
8+
- [**`python mpf_animation_macd.py`**](https://github.com/matplotlib/mplfinance/blob/master/examples/mpf_animation_macd.py)
9+

markdown/subplots.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
## There are two ways to make subplots in mplfinance:
99
- Panels Method
10-
- Matplotlib Method
10+
- External Axes Method
1111
#### Below is a brief description of each method, with links to tutorials on how to use each method:
1212

1313
---
@@ -27,19 +27,25 @@
2727

2828
---
2929

30-
### The Matplotlib Method
31-
* **NOTE: This method is _not yet implemented_. It is presently expected to be available by the end of July 2020.**
32-
* The `matplotlib` method requires the user to call various matplotlib methods, external to `mplfinance`, in order to create a Figure and Axes (**SubPlots**) that the user then passes into `mpf.plot()`.
33-
- **The user is responsible** to configure the size and location of the Axes objects within the Figure.
34-
- **The user is responsible** to display the Figure (as mplfinance will not `show()` the Figure).
35-
* It is expected that this Matplotlib Method will give the user enough full control over the Figure and Axes to do whatever they want to do that matplotlib can do. This includes:
36-
- plotting additional data (such as study data from multiple studies, trading signals, etc.) on as many subplots as desired.
37-
- plotting multiple ohlc/candlestick plots on the same axes.
30+
### [External Axes Method](https://github.com/matplotlib/mplfinance/blob/master/examples/external_axes.ipynb)
31+
* The External Axes method of subplots **allows the user to create and manage their own Figure and Axes (SubPlots), and pass Axes into `mplfinance`**.
32+
* Details on how to use this feature are described below.<br>&nbsp;&nbsp;(code examples can be found in the [**External Axes notebook**](https://github.com/matplotlib/mplfinance/blob/master/examples/external_axes.ipynb)).
33+
* When passing `Axes` into `mplfinance`, some `mplfinance` features may be _not_ available, or may behave differently. For example,
34+
- The user is responsible to configure the size and geometry of the Figure, and size and location of the Axes objects within the Figure.
35+
- The user is responsible to display the Figure by calling **`mplfinance.show()`** (or `pyplot.show()`).
36+
* Passing external Axes into `mplfinance` results in more complex code **but it also provides all the power and flexibility of `matplotlib` for those who know how to and what to use it.** This includes:
37+
- plotting on as many subplots as desired, in any geometry desired.
38+
- plotting multiple ohlc/candlestick plots on the same Figure or Axes.
3839
- plotting multiple candlestick plots side-by-side, or in any other geometry desired.
39-
- It is expected that this Matplotlib Method will also provide the ability to do **event handling** and/or **monitoring** (live updating), but presently I'm not 100% sure about this (due to my own limited experience with matplotlib event handling and monitoring).
40-
41-
* When implemented, the Matplotlib Method will look something like this: Users to use any matplotlib API they want to create their Figures and Axes (aka subplots), however there will be certain restrictions on how they are passed into `mpf.plot()`
42-
43-
1. `mpf.plot()` will have an `ax=` kwarg to pass in **any matplotlib Axes** that you want, however you **must also pass in the Figure** that contains that Axes instance using the `fig=` kwarg. (If you pass in a _different_ Figure, one that does not contain your axes, then `mpf.plot()` won't know it, but behavior will be undefined, i.e. no guarantees).
44-
2. If you specify the `ax=` kwarg when calling `mpf.plot()`, **and you also want to plot volume, then you must also** pass in an Axes instance for the volume; so instead of `volume=True`, you would say `volume=my_axes_for_volume` where my_axes_for_volume is an instance of a matplotlib Axes (i.e. subplot).
45-
3. Similarly, if you specify `ax=` for `mpf.plot()` **then you must also specify** `ax=` for all calls to `make_addplot()`
40+
- anitmating or updating plots in real time.
41+
- event handling
42+
* Use method **`mpf.figure()`** to create Figures.<br>This method behaves exactly like [`pyplot.figure()`](https://matplotlib.org/3.3.0/api/_as_gen/matplotlib.pyplot.figure.html) except that **`mpf.figure()`** also accepts kwarg `style=` to set the mplfinance style.
43+
* Call the usual methods for creating Subplot Axes on the figure:
44+
- [fig.add_subplot()](https://matplotlib.org/3.3.0/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.add_subplot)
45+
- [fig.add_axes()](https://matplotlib.org/3.3.0/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.add_axes)
46+
- [fig.subplots()](https://matplotlib.org/3.3.0/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.subplots)
47+
* When calling the above subplot creation methods, if `fig` was creating using **`mpf.figure()`** then the Subplot Axes will inheret the mpfinance style information from the figure. Alternatively the user may pass in kwarg `style=` to set different style information for an Axes than for the Figure or other Axes.
48+
* Please note the following:
49+
- Use kwarg **`ax=`** to pass **any matplotlib Axes** that you want into **`mpf.plot()`**
50+
- If you also want to plot volume, **then you must pass in an Axes instance for the volume**,<br>&nbsp; so instead of `volume=True`, use **`volume=<myVolumeAxesInstance>`**.
51+
- If you specify `ax=` for `mpf.plot()` **then you must also specify** `ax=` **for all calls to `make_addplot()`**

0 commit comments

Comments
 (0)