【发布时间】:2021-11-07 12:34:40
【问题描述】:
我有一个带有两个美元符号的字符串,我想在我的情节下方用作文本注释。 这段代码创建了一个字符串,你可以看到它的输出。
str=f"最大值:{a},${numerize.numerize(b)}\t"+f"最小值:{c},${numerize.numerize(d)}"
输出:最大值:1396,$544.41M 最小值:1399,$255.31M
但是当我在下面使用 str 时,会更改字体并显示意外字符:
annotations = []
annotations.append(dict(xref='paper', yref='paper', x=0.5, y=-0.15,
xanchor='center', yanchor='top',
text=str,
font=dict(family="Courier New",
size=14,
color='rgb(100,100,100)'),
showarrow=False))
fig.update_layout(annotations=annotations)
以及图中的结果: unexpected annotation
我该如何解决这个问题?谢谢。
【问题讨论】:
标签: python string annotations plotly dollar-sign