python的mplfinance图片元素宽度设置(蜡烛、ohlc 、
Python 2023-09-28
python中使用mplfinance制作蜡烛图,可以手动调整图形中元素的宽度,使用以下两个参数的其中一个就可以了:
scale_width_adjustment=dict(volume=0.4) #以1为原始宽度进行放缩 ,dict中可设置的参数包括 candle, ohlc, volume, or lines update_width_config=dict(candle_linewidth=1.75, line_width=0.7) #更加细致的宽度设置,参数如下:
ohlc ohlc_ticksize 设置ohlc左右标记的长度 ohlc_linewidth 设置ohlc竖线的宽度 candle candle_width 设置蜡烛图柱体的水平宽度 candle_linewidth 设置蜡烛图柱体边缘和烛芯的厚度 volume volume_width 设置成交量柱体的水平宽度 volume_linewidth 设置成交量柱体边缘的厚度 lines line_width 设置均线和其它线性元素的厚度
在plot方法的参数列表中添加参数: mpf.plot(data, update_width_config=dict(candle_linewidth=1.75, line_width=0.7))
设置效果如图:
设置前
设置后