$ tick formatter in Plotly that respects negative values

Viewed 305
1 Answers

If you set the dollar sign in the tick format instead of the prefix, you will get the intended format.

import plotly.graph_objects as go
import numpy as np

fig = go.Figure(go.Scatter(
    x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
    y = np.random.randint(-20,20,12)
))
fig.update_layout(yaxis_tickformat='$,')#yaxis_tickprefix='$',

fig.show()

enter image description here

Related