Alex
Alex

Reputation: 1141

plotly column with vertical border and color for specific column

I am looking for a solution to set a vertical border and color for a specific column(s). for this example the column "Scores".

import plotly.graph_objects as go
import plotly

fig = go.Figure(data=[go.Table(
    header=dict(values=['<b>Values', '<b>Scores', 'column'],
                line_color='darkslategray',
                #fill_color='lightskyblue',
                align='center'),
    cells=dict(values=[[100, 100, 100, 300], # 1st column
                       [90, 90, 90, 270],
                       [90, 90, 90, 270]], # 2nd column
               line_color='darkslategray',
               #fill_color='lightcyan',
               align='center'))
])
fig.update_layout(width=250, height=130)
fig.update_layout(margin=dict(l=10, r=10, t=10, b=10))
fig.show()

the perfect solution I expect looks like the table (created with excel). if somebody only know how to color the column this also would help. Thanks!

enter image description here

Upvotes: 0

Views: 1382

Answers (1)

r-beginners
r-beginners

Reputation: 35230

As far as I know, you cannot change the color of individual ruled lines. The only settings for lines are line width and color. The color for each cell can be specified individually by column or by an array corresponding to the cell.

import plotly.graph_objects as go
import plotly

fig = go.Figure(data=[go.Table(
    header=dict(values=['<b>Values', '<b>Scores', 'column'],
                line_color=['white','mediumpurple','white'],
                fill_color=['white','mediumpurple','white'],
                align='center'),
    cells=dict(values=[[100, 100, 100, 300], # 1st column
                       [90, 90, 90, 270],
                       [90, 90, 90, 270]], # 2nd column
               line_color=['white','mediumpurple','white'],
               fill_color=['white','mediumpurple','white'],
               align='center'))
])
fig.update_layout(width=250, height=130)
fig.update_layout(margin=dict(l=10, r=10, t=10, b=10))
fig.show()

enter image description here

Upvotes: 1

Related Questions