在plotly网站中,有一个示例可以使用shape函数在plotly中添加垂直或水平线。
import plotly.plotly as py
import plotly.graph_objs as go
trace0 = go.Scatter(
x=[2, 3.5, 6],
y=[1, 1.5, 1],
mode='text',
)
data = [trace0]
layout = {
'xaxis': {
'range': [0, 7]
},
'yaxis': {
'range': [0, 2.5]
},
'shapes': [
# Line Horizontal
{
'type': 'line',
'x0': 2,
'y0': 2,
'x1': 5,
'y1': 2,
'line': {
'color': 'rgb(50, 171, 96)',
'width': 4,
'dash': 'dashdot',
}
}
]
}
fig = {
'data': data,
'layout': layout,
}
py.iplot(fig, filename='shapes-lines') …Run Code Online (Sandbox Code Playgroud) 目前我有一个 pandas 数据框:
df = pd.DataFrame({
"date": ["20210613", "20210614", "20210615"],
"user": ["A\nB", "C", "D"],
"machine" : [1, 0, 3]
})
Run Code Online (Sandbox Code Playgroud)
我想知道是否有任何方法可以将此表打印到我的破折号应用程序中,如下所示:
无论使用纯文本打印到 dcc.Textarea 还是 dash_table.DataTable 都可以。
目前我还没有找到一个好的方法来实现这一点,非常感谢。