Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Currency symbol in the y axis scale using plotly method in python

Tags:

python

plotly

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)

like image 289
Maddy6 Avatar asked Jun 18 '26 15:06

Maddy6


1 Answers

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')

like image 64
nicolaskruchten Avatar answered Jun 20 '26 05:06

nicolaskruchten



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!