Graph Object Table - Display Complete Table

Is there a Table or Layout option I’m missing to display a go Table in it’s entirety (no scrolling)? I can set a height but won’t know how many rows and therefore how much height to include the complete table and also not go over.

Looking for scroll=false or something, I guess.

I’m programmatically creating px and go figures and then writing the image/pdf to disk. Table gets cut off if the whole thing isn’t displayed first. Or that’s what I’m experiencing.

Thank you!

import plotly.graph_objects as go

def get_test_table():

    df = px.data.iris()

    fig = go.Figure(data=[go.Table(
    header=dict(values=list(df.columns),
                align='left'),
    cells=dict(values=[df.sepal_length, df.sepal_width, df.petal_length, 
                       df.petal_width, df.species, df.species_id],
               align='left'))])

    return fig

table_fig = get_test_table()

table_fig.update_layout(height=500)

table_fig.show()

An image of the code output above fwiw…

Image from the PDF export…

My suggestion will not work for all environments and purposes, but you can create a table without scrolling by taking the number of rows you want to display and setting a height value per row. This height value is simply calculated excluding titles and margins, so layout issues may remain. You will need to adjust the height values yourself. My understanding is that there is no control over scrolling.

import plotly.express as px
import plotly.graph_objects as go

def get_test_table():

    df = px.data.iris()
    rows = len(df)
    fig = go.Figure(data=[go.Table(
    header=dict(values=list(df.columns),
                align='left'),
    cells=dict(values=[df.sepal_length, df.sepal_width, df.petal_length, 
                       df.petal_width, df.species, df.species_id],
               align='left'))])

    return fig,rows

table_fig,rows = get_test_table()

table_fig.update_layout(height=rows*22)

table_fig.show()

That may work. I can grab the record count ahead of time.

Thanks for the idea!