Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Plotly Table Fill/Line Colors With update_menu

Hi all,

I am trying to update tables in plotly using a dropdown update_menu. I can update all attributes of the table however I come unstuck when trying to set the fill_color or line_color properties. Whenever I select from the dropdown attempting to set these properties, all I receive is the default color scheme. Here is my code below along with an image of the resulting table.

import plotly.graph_objects as go
from plotly.offline import plot

fig = go.Figure()

fig.add_trace(
    go.Table(
        header=dict(
            values=['<b>Name</b>','<b>Age</b>','<b>Gender</b>'],
            font=dict(size=12, family='Arial', color='rgb(0,0,0)'),
            line_color='rgb(0,0,0)',
            fill_color='rgb(255,255,255)',
            align="center"
        ),
        cells=dict(
            values=[['Pete', 'Julie'], [20, 19], ['Male', 'Female']],
            align="center",
            format=[[None, None], ['.0f', '.0f'], [None, None]],
            font=dict(size=11, family='Arial', color='rgb(0,0,0)'),
            fill_color='rgb(255,255,255)',
            line_color='rgb(0,0,0)')
    )
)

fig.update_layout(
    updatemenus=[
        go.layout.Updatemenu(
            active=0,
            buttons=[
                dict(args=[{'header': dict(values=['<b>Name</b>','<b>Age</b>','<b>Gender</b>'],
                                           font=dict(size=12, family='Arial', color='rgb(0,0,0)'),
                                           line_color='rgb(0,0,0)',
                                           fill_color='rgb(255,0,0)',
                                           align="center")}],
                     label='Header Red', method='restyle'),
                dict(args=[{'header': dict(values=['<b>Name</b>','<b>Age</b>','<b>Gender</b>'],
                                           font=dict(size=12, family='Arial', color='rgb(0,0,0)'),
                                           line_color='rgb(0,0,0)',
                                           fill_color='rgb(0,0,255)',
                                           align="center")}],
                     label='Header Blue', method='restyle')
                     ],
            direction="down", pad={"r": 10, "t": 10}, showactive=True,
            x=0.1, xanchor="left", y=1.05, yanchor="top")])

plot(fig, include_plotlyjs=True, filename=r'C:\Colouring_Issue.html')

Table_Coloring_Issue

For info, this has been tried with all combinations of restyle, relayout, update and using multiple dictionaries inside args where appropriate. It is entirely possible I missed something though.