✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Accurately scaled x-axis intervals

Hi–have posted this on SO but want to see if the Plotly community has any thoughts.

I am reading a dataframe from a csv to plot in my Dash Plotly graph. The first column of the csv is Time in the format of hh:mm:ss.xxx, which I am using for the x-axis. However, the time intervals at which data was taken are uneven (usually differing from thousandths of a second to a full second, sometimes more). Right now, my script is just taking the data and plotting it on the x-axis evenly spaced. Is there a way to use Plotly to make my script read the time stamps “smartly” and have it plot the data with spacing between each data point proportional to the amount of time elapsed between them? (Or if it is not possible with Plotly, is it possible with another graphing library that is supported with Dash?)

I was told to convert my Time column to DateTime objects, but I’m trying it out with a really simple script and test csv and Dash is throwing an error.

import plotly.graph_objs as go
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import ntpath
from tkinter import filedialog

import_file_path = filedialog.askopenfilename()
df = pd.read_csv(import_file_path, sep='\t', low_memory = False)
fileName = ntpath.basename(import_file_path)

df['Time'] = pd.to_datetime(df['Time'])     #hardcoded, test csv has two columns Time and dat

app = dash.Dash(__name__, suppress_callback_exceptions=True)

app.layout = html.Div([
        figure = go.Scatter(x=df['Time'], y=df['dat'])

if __name__ == '__main__':

Error I get: