我正在尝试使用plotly绘制条形图,我想在Y轴比例中添加货币“ $”,并且Y轴数字也应以“,”定界(以千为单位,例如1000应为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()
我希望在Y轴比例中添加货币“ $”,并且Y轴数字也应以“,”定界。(以千为单位,例如1000应该是1,000)
您可以使用 fig.update_layout(yaxis_tickprefix = '$', yaxis_tickformat = ',.')
如果您希望小数点后的美分,可以使用 fig.update_layout(yaxis_tickprefix = '$', yaxis_tickformat = ',.2f')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句