未能在 Python 中使用 candlestick_ohlc 绘制 30 分钟烛台
Fail to plot the 30mins candlebar with candlestick_ohlc in Python
我尝试在 Python 中用 candlestick_ohlc 绘制 30 分钟烛台。但它失败了,return 一张奇怪的照片。
ha_bar 是一个包含时间、开盘价、最高价、最低价和收盘价的列表。
ha_bar=[(736389.41666666663, 24.317, 25.109, 24.317, 24.29975),
(736389.4375, 24.308374999999998, 25.529, 25.027750000000001,
25.027750000000001), (736389.45833333337, 24.668062499999998, 25.977,
25.543499999999998, 25.543499999999998), (736389.47847222222, 25.10578125,
25.898, 25.541249999999998, 25.541249999999998), (736389.5625,
25.323515624999999, 25.818000000000001, 25.454000000000001,
25.454000000000001)]
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.finance as mpf
import matplotlib.ticker as ticker
from matplotlib.dates import DateFormatter
fig, ax = plt.subplots()
ax.xaxis.set_major_formatter(DateFormatter('%y-%m-%d %H:%M:%S'))
mpf.candlestick_ohlc(ax, ha_bar,width=0.6)
fig.autofmt_xdate()
plt.show()
如何绘制 30 分钟烛台?
尝试在 mpf.candlestick_ohlc(ax, ha_bar,width=0.6)
中设置 width=0.001
我尝试在 Python 中用 candlestick_ohlc 绘制 30 分钟烛台。但它失败了,return 一张奇怪的照片。
ha_bar=[(736389.41666666663, 24.317, 25.109, 24.317, 24.29975),
(736389.4375, 24.308374999999998, 25.529, 25.027750000000001,
25.027750000000001), (736389.45833333337, 24.668062499999998, 25.977,
25.543499999999998, 25.543499999999998), (736389.47847222222, 25.10578125,
25.898, 25.541249999999998, 25.541249999999998), (736389.5625,
25.323515624999999, 25.818000000000001, 25.454000000000001,
25.454000000000001)]
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.finance as mpf
import matplotlib.ticker as ticker
from matplotlib.dates import DateFormatter
fig, ax = plt.subplots()
ax.xaxis.set_major_formatter(DateFormatter('%y-%m-%d %H:%M:%S'))
mpf.candlestick_ohlc(ax, ha_bar,width=0.6)
fig.autofmt_xdate()
plt.show()
如何绘制 30 分钟烛台?
尝试在 mpf.candlestick_ohlc(ax, ha_bar,width=0.6)
中设置 width=0.001