dsu*_*asa 5 python python-3.x plotly plotly.js plotly-python
我正在尝试将 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()
Run Code Online (Sandbox Code Playgroud)
我可以使用 使 y 轴显示为四舍五入的百分比tickformat = '%',但我无法显示更多小数。Plotly d3 文档(对我来说)不清楚如何做到这一点。任何帮助表示赞赏。
提前致谢。
我相信设置tickformat为".3%"应该可以做到。0.512345以这种方式格式化会产生51.235%.
| 归档时间: |
|
| 查看次数: |
16780 次 |
| 最近记录: |