I am trying to import matplotlib.finance
module in python so that I can make a Candlestick OCHL graph. My matplotlib.pyplot
version is 2.00. I've tried to import it using the following commands:
import matplotlib.finance from matplotlib.finance import candlestick_ohlc
I get this error:
warnings.warn(message, mplDeprecation, stacklevel=1) MatplotlibDeprecationWarning: The finance module has been deprecated in mpl 2.0 and will be removed in mpl 2.2. Please use the module mpl_finance instead.
Then instead of using the above lines in python I tried using the following line:
import mpl_finance
I get this error:
ImportError: No module named 'mpl_finance'
What should I do to import candlestick from matplotlib.pyplot
?
Matplotlib is a Python library that helps to plot graphs. It is used in data visualization and graphical plotting. To use matplotlib, we need to install it.
import matplotlib. pyplot as plt is shorter but no less clear. import matplotlib. pyplot as plt gives an unfamiliar reader a hint that pyplot is a module, rather than a function which could be incorrectly assumed from the first form.
In 2020, one can now pip install mplfinance
I've stopped using mpl_finance (and plotly) since they are too slow. Instead I've written an optimized finance plotting library, finplot, which I use to backtest up to 106 candles.
Here's a small example:
import yfinance as yf import finplot as fplt df = yf.download('SPY',start='2018-01-01', end = '2020-04-29') fplt.candlestick_ochl(df[['Open','Close','High','Low']]) fplt.plot(df.Close.rolling(50).mean()) fplt.plot(df.Close.rolling(200).mean()) fplt.show()
Examples included show SMA, EMA, Bollinger bands, Accumulation/Distribution, Heikin Ashi, on balance volume, RSI, TD sequential, MACD, scatter plot indicators, heat maps, histograms, real-time updating charts and interactive measurements; all with sensible defaults ready for use.
I do dogfooding every day, drop me a note or a pull request if there is something you want. Hope you take it for a spin!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With