🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

Plot annotation: Difficulty in displaying a string with two dollar signs

Hello, everybody!
I have a string with two dollar sign, and I want to be used as a text annotation below my plot.
This code created a string and you can see its output.

str=f"Maximum: {a} , ${numerize.numerize(b)}\t"+f"Minimum: {c} , ${numerize.numerize(d)}" 
Output: Maximum: 1396 , $544.41M	Minimum: 1399 , $255.31M

but when I use str in below, plotly changes font and shows unexpected characters:

annotations = []
annotations.append(dict(xref='paper', yref='paper', x=0.5, y=-0.15,
                              xanchor='center', yanchor='top',
                              font=dict(family="Courier New",

and the result in plot:


How can I fix this issue? Thanx.

1 Like


Need to use HTML printable characters in text that becomes HTML.

like this:

str = (
    f"Maximum: {a} , ${numerize.numerize(b)}\t"
    + f"Minimum: {c} , ${numerize.numerize(d)}"

I think this is caused by the Latex typesetting feature that is done when you have any string between two dollar signs ($) e.g. $this latex$. Not sure this would work but you can also try escaping the dollar sign with a backslash before the sign e.g. \$this latex\$.