6

I'm trying to plot a bar chart using plotly and I wanted to add a currency "$" in the Y axis scale and also the Y axis figure should be delimited by "," (In Thousands, e.g, 1000 should be 1,000)

import plotly.graph_objects as go  

fig = go.Figure()       

fig.add_trace(go.Bar(x=["Apple", 'Mango', 'Banana'], y=[4000, 3000, 5000])) 

fig.show()       

I expect to add a currency "$" in the Y axis scale and also the Y axis figure should be delimited by ",". (In Thousands, e.g, 1000 should be 1,000)

Andrew Regan
  • 5,087
  • 6
  • 37
  • 73
Maddy6
  • 367
  • 1
  • 3
  • 14

1 Answers1

10

You can use fig.update_layout(yaxis_tickprefix = '$', yaxis_tickformat = ',.')

If you want the cents after the decimal point, you can use fig.update_layout(yaxis_tickprefix = '$', yaxis_tickformat = ',.2f')

nicolaskruchten
  • 26,384
  • 8
  • 83
  • 101