mplfinance - 如何在每个烛台顶部显示数字
如何在 mplfinance 上的每个烛台上显示字母或数字?例如,我想在每个烛台顶部显示 0(表示绿色条)和 1(表示红色条),而不是标记。
How can I display letters or numbers on each candle stick on mplfinance? For example, I want to show 0 (for green bars) and 1 (for red bars) on top of each candle stick, instead of marks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
根据@Daniel Goldfarb 的帖子,我使用下面的代码在每个烛台顶部显示数字:
apds=[]
data["buy"]= np.where(buy, '$0
假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data
) /code>、买入
和 ohlc
信号。
此代码在绿色蜡烛和 顶部以绿色显示 0
(颜色代码中的 g
表示 mplfinance
标记颜色中的绿色) >1
红色蜡烛顶部的红色 (r
)。
在我看来,最好在绿色蜡烛下方显示 0
,为此,您可以将 data['low']
设置为源而不是 data['high']
并将 Bitcoin
的 buyCoef
设置为 1.00001
(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01
。如果您喜欢这个想法,可以使用以下代码:
apds=[]
data["buy"]= np.where(buy, '$0
, 'None')
data["sell"]= np.where(sell, '$1
假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data
) /code>、买入
和 ohlc
信号。
此代码在绿色蜡烛和 顶部以绿色显示 0
(颜色代码中的 g
表示 mplfinance
标记颜色中的绿色) >1
红色蜡烛顶部的红色 (r
)。
在我看来,最好在绿色蜡烛下方显示 0
,为此,您可以将 data['low']
设置为源而不是 data['high']
并将 Bitcoin
的 buyCoef
设置为 1.00001
(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01
。如果您喜欢这个想法,可以使用以下代码:
, 'None')
buyMarker=list(data['buy'].values)
buyColor=['g']*len(data)
sellMarker=list(data['sell'].values)
sellColor=['r']*len(data)
buyCoef = 1.0001
sellCoef = 1.0001
apds.append(mpf.make_addplot(buyCoef*data['high'],type='scatter',marker=buyMarker,markersize=45,color=buyColor))
apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor))
mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500)
假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data
) /code>、买入
和 ohlc
信号。
此代码在绿色蜡烛和 顶部以绿色显示 0
(颜色代码中的 g
表示 mplfinance
标记颜色中的绿色) >1
红色蜡烛顶部的红色 (r
)。
在我看来,最好在绿色蜡烛下方显示 0
,为此,您可以将 data['low']
设置为源而不是 data['high']
并将 Bitcoin
的 buyCoef
设置为 1.00001
(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01
。如果您喜欢这个想法,可以使用以下代码:
, 'None')
data["sell"]= np.where(sell, '$1
, 'None')
data["sell"]= np.where(sell, '$1
假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:data
) /code>、买入
和 ohlc
信号。
此代码在绿色蜡烛和 顶部以绿色显示 0
(颜色代码中的 g
表示 mplfinance
标记颜色中的绿色) >1
红色蜡烛顶部的红色 (r
)。
在我看来,最好在绿色蜡烛下方显示 0
,为此,您可以将 data['low']
设置为源而不是 data['high']
并将 Bitcoin
的 buyCoef
设置为 1.00001
(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01
。如果您喜欢这个想法,可以使用以下代码:
, 'None')
buyMarker=list(data['buy'].values)
buyColor=['g']*len(data)
sellMarker=list(data['sell'].values)
sellColor=['r']*len(data)
buyCoef = 1.0001
sellCoef = 1.0001
apds.append(mpf.make_addplot(buyCoef*data['high'],type='scatter',marker=buyMarker,markersize=45,color=buyColor))
apds.append(mpf.make_addplot(sellCoef*data['high'],type='scatter',marker=sellMarker,markersize=45,color=sellColor))
mpf.plot(data, figratio=(8,4), type='candle', addplot=apds, volume=False, style='yahoo', datetime_format='%Y-%m-%d %H:%M:%S', warn_too_much_data=10500)
假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:
data
) /code>、买入
和 ohlc
信号。
此代码在绿色蜡烛和 顶部以绿色显示
红色蜡烛顶部的红色 (0
(颜色代码中的 g
表示 mplfinance
标记颜色中的绿色) >1r
)。
在我看来,最好在绿色蜡烛下方显示 0
,为此,您可以将 data['low']
设置为源而不是 data['high']
并将 Bitcoin
的 buyCoef
设置为 1.00001
(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01
。如果您喜欢这个想法,可以使用以下代码:
假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:
data
) /code>、买入
和 ohlc
信号。
此代码在绿色蜡烛和 顶部以绿色显示
红色蜡烛顶部的红色 (0
(颜色代码中的 g
表示 mplfinance
标记颜色中的绿色) >1r
)。
在我看来,最好在绿色蜡烛下方显示 0
,为此,您可以将 data['low']
设置为源而不是 data['high']
并将 Bitcoin
的 buyCoef
设置为 1.00001
(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01
。如果您喜欢这个想法,可以使用以下代码:
假设您有一个包含 sell< 的 pandas 数据框(在我的示例中:
data
) /code>、买入
和 ohlc
信号。
此代码在绿色蜡烛和 顶部以绿色显示
红色蜡烛顶部的红色 (0
(颜色代码中的 g
表示 mplfinance
标记颜色中的绿色) >1r
)。
在我看来,最好在绿色蜡烛下方显示 0
,为此,您可以将 data['low']
设置为源而不是 data['high']
并将 Bitcoin
的 buyCoef
设置为 1.00001
(今天的价格是 68000),这样您就可以调整系数根据到该货币的价格。例如,如果该货币的价格是两位数,那么它就变成其系数1.01
。如果您喜欢这个想法,可以使用以下代码:
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有多种方法可以做到这一点。您可以使用
Axes.text()
或Axes.annotate()
来完成此操作,如以下示例所示:然而,最简单的解决方案可能是 使用
mpf.make_addplot()
创建一个type=scatter
绘图,您希望在其中显示数字,然后传入标记序列为marker=
kwarg (make_addplot),并使用 数学文本标记 用于标记(例如“$1$”是“1”等)单击此处获取示例代码。
< em>可能值得一读:
There are a number of ways to do this. You can do it with
Axes.text()
or withAxes.annotate()
as noted in these examples:However, probably the easiest solution is to use
mpf.make_addplot()
to create atype=scatter
plot where you want the numbers to appear, and then pass in a sequence of markers for themarker=
kwarg (of make_addplot), and use Mathtext markers for the markers (for example "$1$" is a '1', etc.)Click here for example code.
Other discussions that may be worth reading through: