Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert Y axis in Python dash

I have a data from csv file

id lap_time LapNumber
175 0 days 00:02:04.853000 2
176 0 days 00:02:01.375000 3
177 0 days 00:01:59.889000 4
178 0 days 00:01:58.425000 5
179 0 days 00:01:57.786000 6
180 0 days 00:02:10.329000 7
181 0 days 00:01:53.315000 8
182 0 days 00:01:49.771000 9

when I try to display a graph with a dash

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"},
            },
        ),
...

Unfortunately I gets incorect plot

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When I do the same using go.figure:

import plotly.graph_objects as go
fig = go.Figure([go.Scatter(x=lec['LapNumber'], y=lec['LapTime'])])

I got correct plot

Do you know how to solve this issue on dcc.Graph ?
Need to add some parameters to X axis ?

Thanks for hint

>Solution :

You can follow this approach:

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading