K线图绘制

import pandas as pd
import matplotlib.pyplot as plt
import mpl_finance as mpf

def candi_draw(dataframe,path,filename,num):
    fig, ax = plt.subplots(figsize=(6,4))
    fig.subplots_adjust(bottom=0.2)
    mpf.candlestick2_ohlc(ax,dataframe['OPEN'], dataframe['HIGH'],
                          dataframe['LOW'],dataframe['CLOSE'], width=0.9,
                          colorup='r',colordown='g')
    ax.autoscale_view()
    fig = plt.gcf()
    fig.savefig(path + '{}-{}.jpg'.format(filename,num),bbox_inches = 'tight')
    plt.close()

猜你喜欢

转载自blog.csdn.net/changyan_123/article/details/83386300