0

我正在寻找一种解决方案来为特定列设置垂直边框和颜色。对于此示例,列“分数”。

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()

我期望的完美解决方案看起来像表格(使用 excel 创建)。如果有人只知道如何为列着色,这也会有所帮助。谢谢!

在此处输入图像描述

4

1 回答 1

1

据我所知,您无法更改单个格线的颜色。线条的唯一设置是线条宽度和颜色。每个单元格的颜色可以按列或单元格对应的数组单独指定。

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()

在此处输入图像描述

于 2021-04-08T07:43:36.470 回答