Controlling individual column widths in Plotly tables

Is it possible to set individual columns widths in plotly similar to calling set_width in matplotlib?


1 Like

I have the same query…did you get a response…?

Unfortunately no response yet.

I’ve figured out a bit of a “hack” to control the widths by editing components of the FF structure. It’s not very fine-tuned at this point, but it works.

Suppose you’ve created a table using “plotly.figure_factory.create_table”, which outputs a dictionary object. All of the table layout info is under the “layout” entry in the dict. The table entries themselves each have attributes under the “annotations” sub-entry (since the plotly table is really just a plot, not a “real” table). Each entry in the “annotations” then has an x and y setting that determines where the point sits on the plot. The function below is an example of how to iterate over these entries and update column start points. I haven’t worked out the details of relative scaling in any real sense. Hopefully this provides you with a starting point at least for accomplishing what you want.

def adjust_column_widths(ff_table, n_cols=2, new_xs=[1.]):
for i,entry in enumerate(ff_table[‘layout’][‘annotations’]):
if i % n_cols!=0:
entry[‘x’] = new_xs[(i % n_cols)-1]

Just as a work-around, you could try to add dummy columns with empty strings. That did it for me.