在 matplotlib 烛台图表上添加线条和几何形状
Adding lines and geometric shapes on matplotlib candlestick chart
我使用 matplotlib.finance
在 python 上制作了烛台货币图表。一切正常,但我想在实际图表上添加线条和形状。当我在 matplotlib 中使用普通类型的图表时。我会做:
plt.plot([xmin, xmax], [0.0005,0.0005], linewidth=3, color='purple')
以0.0005价格level.But画一条从xmin
到xmax
(待定义)的水平线,因为我使用的是candlestick2_ohlc
方法,我不知道'我真的不知道如何进行...
这是我的:
这就是我想要得到的:
也可以绘制和填充三角形吗?
绘制水平线最简单的方法是使用
plt.axhline(y=1.066)
绘图段
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)
就这么简单!
我使用 matplotlib.finance
在 python 上制作了烛台货币图表。一切正常,但我想在实际图表上添加线条和形状。当我在 matplotlib 中使用普通类型的图表时。我会做:
plt.plot([xmin, xmax], [0.0005,0.0005], linewidth=3, color='purple')
以0.0005价格level.But画一条从xmin
到xmax
(待定义)的水平线,因为我使用的是candlestick2_ohlc
方法,我不知道'我真的不知道如何进行...
这是我的:
这就是我想要得到的:
也可以绘制和填充三角形吗?
绘制水平线最简单的方法是使用
plt.axhline(y=1.066)
绘图段
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)
就这么简单!