Gallery¶
Chart examples rendered with the bundled AAPL sample data (mplchart.samples).
Each chart is produced by the code cell right above it — copy it and adapt.
In [1]:
Copied!
from mplchart.chart import Chart
from mplchart.samples import sample_prices
from mplchart.primitives import Candlesticks, Volume, Pane, LinePlot, TrendLines
from mplchart.indicators import SMA, BBANDS, RSI, MACD, MACDV, STOCH, KELTNER, DONCHIAN, DMI, BBP, BBW
prices = sample_prices()
from mplchart.chart import Chart
from mplchart.samples import sample_prices
from mplchart.primitives import Candlesticks, Volume, Pane, LinePlot, TrendLines
from mplchart.indicators import SMA, BBANDS, RSI, MACD, MACDV, STOCH, KELTNER, DONCHIAN, DMI, BBP, BBW
prices = sample_prices()
Candlesticks with Volume¶
In [2]:
Copied!
Chart(prices, title="Candlesticks with Volume", max_bars=250).plot(
Candlesticks(), Volume(),
).show()
Chart(prices, title="Candlesticks with Volume", max_bars=250).plot(
Candlesticks(), Volume(),
).show()
Simple Moving Averages¶
In [3]:
Copied!
Chart(prices, title="Simple Moving Averages", max_bars=250).plot(
Candlesticks(), SMA(50), SMA(200),
).show()
Chart(prices, title="Simple Moving Averages", max_bars=250).plot(
Candlesticks(), SMA(50), SMA(200),
).show()
Bollinger Bands¶
In [4]:
Copied!
Chart(prices, title="Bollinger Bands", max_bars=250).plot(
Candlesticks(), BBANDS(20),
).show()
Chart(prices, title="Bollinger Bands", max_bars=250).plot(
Candlesticks(), BBANDS(20),
).show()
Relative Strength Index¶
In [5]:
Copied!
Chart(prices, title="Relative Strength Index", max_bars=250).plot(
Candlesticks(),
Pane("above", yticks=(30, 50, 70)),
LinePlot(RSI(14), overbought=70, oversold=30),
).show()
Chart(prices, title="Relative Strength Index", max_bars=250).plot(
Candlesticks(),
Pane("above", yticks=(30, 50, 70)),
LinePlot(RSI(14), overbought=70, oversold=30),
).show()
MACD with Volume¶
In [6]:
Copied!
Chart(prices, title="MACD with Volume", max_bars=250).plot(
Candlesticks(), Volume(), Pane("below"), MACD(),
).show()
Chart(prices, title="MACD with Volume", max_bars=250).plot(
Candlesticks(), Volume(), Pane("below"), MACD(),
).show()
Stochastic Oscillator¶
In [7]:
Copied!
Chart(prices, title="Stochastic Oscillator", max_bars=250).plot(
Candlesticks(), Pane("below"), STOCH(14),
).show()
Chart(prices, title="Stochastic Oscillator", max_bars=250).plot(
Candlesticks(), Pane("below"), STOCH(14),
).show()
Keltner Channel¶
In [8]:
Copied!
Chart(prices, title="Keltner Channel", max_bars=250).plot(
Candlesticks(), KELTNER(20),
).show()
Chart(prices, title="Keltner Channel", max_bars=250).plot(
Candlesticks(), KELTNER(20),
).show()
Trend Lines (experimental)¶
In [9]:
Copied!
Chart(prices, title="Trend Lines (experimental)", max_bars=250).plot(
Candlesticks(), TrendLines(),
).show()
Chart(prices, title="Trend Lines (experimental)", max_bars=250).plot(
Candlesticks(), TrendLines(),
).show()
Donchian Channel¶
In [10]:
Copied!
Chart(prices, title="Donchian Channel", max_bars=250).plot(
Candlesticks(), DONCHIAN(20)
).show()
Chart(prices, title="Donchian Channel", max_bars=250).plot(
Candlesticks(), DONCHIAN(20)
).show()
Directional Movement Index¶
In [11]:
Copied!
Chart(prices, title="Directional Movement Index", max_bars=250).plot(
Candlesticks(),
).pane("below").plot(
DMI(14),
).show()
Chart(prices, title="Directional Movement Index", max_bars=250).plot(
Candlesticks(),
).pane("below").plot(
DMI(14),
).show()
MACD-V¶
In [12]:
Copied!
Chart(prices, title="MACD-V", max_bars=250).plot(
Candlesticks(), Volume(),
).pane("below").plot(
MACDV(),
).show()
Chart(prices, title="MACD-V", max_bars=250).plot(
Candlesticks(), Volume(),
).pane("below").plot(
MACDV(),
).show()
Bollinger %B and Bandwidth¶
In [13]:
Copied!
Chart(prices, title="Bollinger %B and Bandwidth", max_bars=250).plot(
Candlesticks(), BBANDS(20),
).pane("above").plot(
BBP(20),
).pane("below").plot(
BBW(20),
).show()
Chart(prices, title="Bollinger %B and Bandwidth", max_bars=250).plot(
Candlesticks(), BBANDS(20),
).pane("above").plot(
BBP(20),
).pane("below").plot(
BBW(20),
).show()