您可以通过在fig.write_image 中设置height 来调整您的pdf 表格,就像这样fig.write_image("C://imagesplotly//fig1.pdf", height=yourDesiredHeight)。
代码 1 - 图:
import plotly.graph_objects as go
import numpy as np
np.random.seed(123)
lst1=np.random.uniform(low=0, high=100, size=10).tolist()
lst2=np.random.uniform(low=0, high=100, size=10).tolist()
fig = go.Figure(data=[go.Table(cells=dict(values=[np.random.rand(100,1), np.random.rand(100,1)]))])
fig.show()
Jupyter 输出:
我认为将绘图表行的默认像素数乘以数据长度是个好主意,但我无法弄清楚默认值。肯定不是255,但下面的 sn-p 中的设置将捕获整个表,以获得长度为 100 的列表。
代码 2 - pdf 输出:
pix = 225
datasize = len(lst1)
fig.write_image("C://imagesplotly//fig1.pdf", height=pix*datasize)
pdf输出(略):