December 2018
Beginner to intermediate
682 pages
18h 1m
English
We introduced candlestick plots for showing Open-High-Low-Close (OHLC) financial data. In addition, a 3D bar chart can be employed to show OHLC across time. The next figure shows a typical example of plotting a 5-day OHLC bar chart:
import matplotlib.pyplot as pltimport numpy as npfrom mpl_toolkits.mplot3d import Axes3D# Get 1 and every fifth row for the 5-day AAPL OHLC dataohlc_5d = stock_df[stock_df["Company"]=="AAPL"].iloc[1::5, :]fig = plt.figure()ax = fig.add_subplot(111, projection='3d')# Create one color-coded bar chart for Open, High, Low and Close prices.for color, col, z in zip(['r', 'g', 'b', 'y'], ["Open", "High", "Low", "Close"], [30, 20, 10, 0]): xs = np.arange(ohlc_5d.shape[0]) ys = ohlc_5d[col] # Assign color ...