2017-04-05 197 views
0

我想在matplotlib阴谋的烛台周围添加一个黑色的边框。下面是我试过的代码,这就造成了一个错误(TypeError: candlestick_ohlc() got an unexpected keyword argument 'edgecolor'如何用matplotlib为烛台添加边框或边缘颜色?

candlestick_ohlc(ax2, ohlc, width=0.9, edgecolor = 'k', colorup='g', colordown='r') 

edgecolor = 'k'是无法识别的。我在fill_between函数中使用过它,但candlestick_ohlc不接受它。

这是结果我想:

enter image description here

这是我目前有:

enter image description here

谢谢!

回答

1

From the documentation,candlestick_ohlc返回一个列表元组,一个列表的行,一个矩形。您可以存储每个这些列表,然后遍历每个元素以更改其属性。

ls, rs = candlestick_ohlc(ax, quotes, width=0.6, colorup='b', colordown='g') 

for r in rs: 
    r.set_edgecolor('r') 
    r.set_linewidth(1.) 

enter image description here

+0

的感谢!那工作。任何想法如何消除从棍子模糊/霾? – hanumanDev