plotly.graph_objects.table 정적 테이블

Jan 22 2021

나는 plotly.go를 사용하여 테이블을 만들고 html로 내보내지만 테이블의 열은 정적이 아니므로 마우스로 끌어서 재 배열 할 수 있습니다. html로 내보내는 동안 테이블을 정적으로 만드는 간단한 방법을 찾으려고합니다.

import pandas as pd
import plotly.graph_objects as go

df = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
                   columns=['a', 'b', 'c'])

fig = go.Figure(data=[go.Table(
    header=dict(
        values=list(df),
        line_color='darkslategray',
        fill_color = 'lightskyblue',
        align='center'),
    cells=dict(
        values=[df.a, df.b, df.c],
        line_color='darkslategray',
        fill_color='lightcyan',
        align='center'))

])
fig.show()
fig.to_html('table.html')

을 사용해 staticPlot: true보았지만 graph_objects의 속성 인 것 같지 않습니다.

답변

1 J-Help Jan 25 2021 at 22:51

코드에 다음을 추가하여 정적 테이블을 얻을 수있었습니다.

fig.show()
fig.to_html('table.html', config={'staticPlot': True})

한 가지 명심해야 할 점은 마우스 아이콘이 여전히 열을 드래그 할 수있는 것처럼 변경되지만 열은 정적이라는 것입니다.