🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

Plotly table columns overlap PYTHON

I’m trying to make a table in python with around twelve columns, but when I create the table using the following command:

table = FF.create_table(df)
plot_urlMobile = py.iplot(table,filename=‘summary_mobile_2015-12-10_2015-12-16’,overwrite=True,auto_open=True,sharing=‘private’)

the information in the table columns overlap.

Is there a way to change the default column width?

You can set (in this case increase) the overall width of the table by

table = FF.create_table(df) table.layout.width=1000 #width in pixels plot_urlMobile = py.iplot(table,filename='summary_mobile_2015-12-10_2015-12-16',overwrite=True,auto_open=True,sharing='private')

(Unfortunately, you can’t control individual column widths with FF.create_table() at this time)

Thanks for the response chelsea! Unfortunately, that command doesn’t help since there seems to be a limit (1000 pixels) on how wide you can make the table. I need it to be about 1500 px wide.

That’s true If you’re plotting in an ipython notebook.
Two other points that might help you:

If you send the table to plotly it can be displayed at a greater width i.e.
table = FF.create_table(df) table.layout.width=1500 #width in pixels plot_urlMobile = py.plot(table,filename='summary_mobile_2015-12-10_2015-12-16',overwrite=True,auto_open=True,sharing='private')

Also you have the option of making the font smaller by adding:

table = FF.create_table(df)
for i in range(len(table.layout.annotations)):
    (table.layout.annotations[i].font.size = 8
py.iplot((table, filename='annotated_heatmap_numpy')```

How can I have automated width control based on length of the string.
I have a problem as there is just one column which doesnt get fit and having a overall width setting will force other columns to be out of the border.

@p2ya Plotly also has a new Python table type that does text wrapping, take a look at this:

https://plot.ly/~jackp/18049

The official documentation is not quite finished yet, but you can gleam the other options from the plotly.js attributes file:

Hi Jack,
that looks like what I need to implement.
however how I can I do it ?
I am using following code now which the headers overlap, I also like to align the content of each cell in centre:

@p2ya Here are a few recipes to get you started with the new table trace type in Python:

https://plot.ly/~jackp/18049/import-plotlyoffline-as-py/

https://plot.ly/~jackp/18023/import-plotlyoffline-as-py/

to me it seems that this is done manually by setting the width.
is there anyway that we can automatically adjust cells’ width based on their content ?

@jack can I have your email and send you sample data to fix this ? I am struggling to make this more automated as the data structure might change

@p2ya https://support.plot.ly/libraries/python

Thanks @jack I automated that and it works fine excpet when I want to show it as an image.
Then the left side doesnt get shown completely.
Any solution to fix this ?
I played around with margins but that didnt help.

Also how can I align middle and centre text in cells?

Anything on aligning the center text in headers and cells ? Thanks