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 the font and shows unexpected characters:
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)
and the result in the plot: unexpected annotation
How can I fix this issue? Thanks.
import plotly.graph_objects as go
from numerize import numerize
fig = go.Figure()
# # Output: Maximum: 1396 , $544.41M Minimum: 1399 , $255.31M
a = 1396
b = 544.41 * 10 ** 6
c = 1399
d = 255.31 * 10 ** 6
str = (
f"Maximum: {a} , ${numerize.numerize(b)}\t"
+ f"Minimum: {c} , ${numerize.numerize(d)}"
)
ano
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)