代码
weeknum_=4 #5
fig,ax=gs.plt.subplots()
import candleplotter as cplt
title=''
col_cycler=gs.mpl.rcParams['axes.prop_cycle']
# print(cycler.__iter__().__next__()['color'])
weekday_dict=dict(zip(range(1,6,1), range(100, 125, 5)))
for name, coldict in zip(
sorted(set(df[df.weeknum==weeknum_]['datestr'])),
col_cycler,
):
dfgroup = df[df.weeknum==weeknum_].groupby(by='datestr').get_group(name)
value0 = gs.deepcopy(dfgroup.open.iloc[0])
weekday = dfgroup.index[-1].isocalendar()[2]
value1 = weekday_dict[weekday]
for column in 'open high low close vwap'.split():
dfgroup[column] = dfgroup[column] / value0 * value1
# print(dfgroup)
cp = cplt.CandlePlotter(dfgroup,
p=dict(code=kzz.code, dname=kzz.name,
freq=f'{gs.Loaddata.lidu[catalog]}分钟K线数据',
),
)
cp.p['figsize'] = [12,8] #plt.rcParams['figure.figsize']
cp.p['title'] = title or '蜡烛图和技术指标'
cp._candles(ax=ax, fig=fig, **coldict) #dict(list(col_cycler)[0]))
label= dfgroup.index[-1].isoformat()[:10] + f'({cp.cweekday[str(weekday)]})'
cp._plot_trend(cols=['vwap'],
legend=True, label=label,
custom_fig=0,
**coldict)