python - 绘图地保存没有空格的表

2024-01-28

i generate a table in python with plotly and i save it as png . but the saved png has a lot of whitespace. i there a solution that the png/or image is "filled" or "Full-screen/image". enter image description here

我用以下内容生成表格:

import plotly.graph_objects as go

fig = go.Figure(data=[go.Table(header=dict(values=['A Scores', 'B Scores']),
                 cells=dict(values=[[100, 90, 80, 90], [95, 85, 75, 95]]))
                     ])
plotly.io.write_image(fig, file='example_table.png', format='png')

感谢您的想法和解决方案。问候亚历克斯


使用此代码:

import plotly.graph_objects as go    
fig = go.Figure(data=[go.Table(header=dict(values=['A Scores', 'B Scores']),
                 cells=dict(values=[[100, 90, 80, 90], [95, 85, 75, 95]]))
                     ])
fig.update_layout(
    autosize=False,
    margin = {'l':0,'r':0,'t':0,'b':0},
    height = 125
)
fig.write_image("fig1.png")

the update_layout将帮助您确定图表的高度和重量。

Output: enter image description here

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

python - 绘图地保存没有空格的表 的相关文章

随机推荐