2017-04-09 107 views
0

我已经使用matplotlib.finance在python上制作了烛台货币图表。一切正常,但我想在实际图表中添加线条和形状。当我在matplotlib中使用普通类型的图表时。我会做:在matplotlib烛台图表中添加线条和几何形状

plt.plot([xmin, xmax], [0.0005,0.0005], linewidth=3, color='purple') 

xmin画一条水平线xmax(待定)以0.0005的价格level.But因为我使用的方法candlestick2_ohlc我真的不知道如何着手。 ..

这是我有:enter image description here

这就是我希望得到:enter image description here

而且是可以绘制和填充三角形?

回答

1

绘图段

plt.plot([xmin, xmax], [ymin, ymax]) 

绘制三角形

x = [x1, x2] 
y = [y1, y2] 
plt.fill(x,y) 

个绘制多边形

x = [x1,...,xn] 
y = [y1,...,yn] 
plt.fill(x,y) 

就是这么简单!

enter image description here

0

绘制水平线的最简单的方法是使用

plt.axhline(y=1.066) 
+0

谢谢你,你知道任何方式绘制线段和三角形? – Ivan

+0

一般而言,您可以绘制[本示例]中显示的形状(http://matplotlib.org/examples/shapes_and_collections/artist_reference.html)。三角形将是一个'RegularPolygon'。 – ImportanceOfBeingErnest