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, eg, 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, eg, 1000 should be 1,000)
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')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.