plotly table cell color based on values

Solutions on MaxInterview for plotly table cell color based on values by the best coders in the world

showing results for - "plotly table cell color based on values"
Helene
29 Nov 2019
1import plotly.graph_objects as go
2from plotly.colors import n_colors
3import numpy as np
4np.random.seed(1)
5
6colors = n_colors('rgb(255, 200, 200)', 'rgb(200, 0, 0)', 9, colortype='rgb')
7a = np.random.randint(low=0, high=9, size=10)
8b = np.random.randint(low=0, high=9, size=10)
9c = np.random.randint(low=0, high=9, size=10)
10
11fig = go.Figure(data=[go.Table(
12  header=dict(
13    values=['<b>Column A</b>', '<b>Column B</b>', '<b>Column C</b>'],
14    line_color='white', fill_color='white',
15    align='center',font=dict(color='black', size=12)
16  ),
17  cells=dict(
18    values=[a, b, c],
19    line_color=[np.array(colors)[a],np.array(colors)[b], np.array(colors)[c]],
20    fill_color=[np.array(colors)[a],np.array(colors)[b], np.array(colors)[c]],
21    align='center', font=dict(color='white', size=11)
22    ))
23])
24
25fig.show()
26
similar questions
queries leading to this page
plotly table cell color based on values