我有一個來自 csv 檔案的資料
| ID | 單圈時間 | 圈數 |
|---|---|---|
| 175 | 0 天 00:02:04.853000 | 2 |
| 176 | 0 天 00:02:01.375000 | 3 |
| 177 | 0 天 00:01:59.889000 | 4 |
| 178 | 0 天 00:01:58.425000 | 5 |
| 179 | 0 天 00:01:57.786000 | 6 |
| 180 | 0 天 00:02:10.329000 | 7 |
| 181 | 0 天 00:01:53.315000 | 8 |
| 182 | 0 天 00:01:49.771000 | 9 |
當我嘗試用破折號顯示圖表時
import dash
from dash import dcc
from dash import html
import pandas as pd
import fastf1
from fastf1 import plotting
import plotly.express as px
...
...
dcc.Graph(
figure={
"data": [
{
"x": lec['LapNumber'],
"y": lec['LapTime'],
"type": "lines",
},
],
"layout": {"title": "Test Date"},
},
),
...
不幸的是我得到了不正確的情節
當我使用 go.figure 做同樣的事情時:
import plotly.graph_objects as go
fig = go.Figure([go.Scatter(x=lec['LapNumber'], y=lec['LapTime'])])
我得到了正確的情節
你知道如何在 dcc.Graph 上解決這個問題嗎?需要在 X 軸上添加一些引數嗎?
謝謝提示
uj5u.com熱心網友回復:
您可以遵循以下方法:
from dash import dcc
import plotly.graph_objs as go
fig = go.Figure([go.Scatter(x=lec['LapNumber'], y=lec['LapTime'])])
dcc.Graph(figure=fig)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/456778.html
