我正在尝试将我的 Plotly 条形图 x 轴格式化为带 3 个小数点的百分比。
import chart_studio.plotly as py #for plotting
import plotly.graph_objs as go
y = ['niner', 'deuce', 'checker']
x = [0.03, -0.05, 0.075]
fig = go.Figure(go.Bar(y = y, x = x,
name = 'returns',
orientation = 'h',
marker = dict(color = '#003663',
line = dict(
color = '#afafaf',
width = 1.5)
)))
fig.update_layout(
title = 'Why So Hard Plotly?',
xaxis = dict(
tickformat = '%.format.%3f',
title = 'Returns',
fixedrange = True,
hoverformat = '.3f',
showgrid = True),
yaxis = dict(
fixedrange = True,
hoverformat = '.3f',
showgrid = True,
),
bargap = 0.2,
barmode = 'relative',
)
fig.update_yaxes(automargin=True)
fig.show()
我可以使用 让 y 轴显示为四舍五入的百分比tickformat = '%'
,但我无法显示更多小数。Plotly d3 文档不清楚(对我来说)如何做到这一点。任何帮助表示赞赏。
提前致谢。