发表自话题:k线图坐标上的数字
使用python绘制股票k线图,该例子从本地加载的数据
import numpy as np
import matplotlib.pyplot as plt
import time
from matplotlib.finance import candlestick_ohlc
import pandas as pd
plt.style.use('ggplot')
df = pd.read_excel('testdata.xlsx')
dates=df["dates"][1:].values.tolist()
volumns = df["counts"][1:].values.tolist()
open=df["open"][1:].values.tolist()
close=df["close"][1:].values.tolist()
low=df["low"][1:].values.tolist()
high=df["high"][1:].values.tolist()
timestamp = [time.mktime(date.timetuple()) for date in dates]
quotes = zip(timestamp,open,high,low,close)
left,width = 0.1,0.8
rect_vol = [left,0.1,width,0.26]
rect_main = [left,0.4,width,0.5]
fig = plt.figure()
ax_vol = fig.add_axes(rect_vol)
ax_vol.fill_between(dates,volumns,color='y')
ax_main=fig.add_axes(rect_main)
candlestick_ohlc(ax_main,quotes=quotes,width=0.6,colorup='r',colordown='g')
ax_main.axes.get_xaxis().set_visible(False)
ax_main.set_title('Stock INTC Price and Volume')
plt.show()
标签组:[python]
上一篇:球员能力图和股票K线图
2021-08-19
2021-08-12
2021-08-04
2021-07-28
2021-07-28
2021-07-28
股票K线图入门70种经典的K线组合形态(史上最全),快快拿走!
2021-07-28
2021-07-28
2021-07-28
2021-07-28