问题
在我的漏斗图中,我想将textinfo注释更改为我的客户语言(中文).To更具体,我想将“初始值”改为"总体",将“前文”更改为"上层“。另外,我也想改变内部值的格式,例如"3000“到"3千”。有什么办法吗?非常感谢!

代码
from plotly import graph_objects as go
fig = go.Figure()
fig.add_trace(go.Funnel(
name = 'Label1',
y = ["stage1", "stage2", "stage3"],
x = [3000, 2000, 1000],
textposition = "inside",
textinfo = "value+percent previous+percent initial"))
fig.add_trace(go.Funnel(
name = 'Label2',
orientation = "h",
y = ["stage1", "stage2", "stage3"],
x = [4000, 2500, 1000],
textposition = "inside",
textinfo = "value+percent previous+percent initial"))
fig.update_layout(legend=dict(
orientation="h",
yanchor="bottom",
y=1.02,
xanchor="right",
x=0.5
)
)
fig.update_traces(textposition='auto', textfont_size=16)
fig.show()s参考文献
发布于 2021-05-12 09:01:33
您可以使用文本模板自定义它。我把左边修改成一个样本。
fig.add_trace(go.Funnel(
name = 'Label1',
y = \["stage1", "stage2", "stage3"\],
x = \[3000, 2000, 1000\],
textposition = "inside",
textinfo = "value+percent previous+percent initial",
texttemplate='%{value}<br>%{percentInitial}总体<br>%{percentPrevious}上层'
))

https://stackoverflow.com/questions/67500040
复制相似问题