%f — fractional seconds (milliseconds)¶The new %f pattern formats the millisecond component of a datetime, zero-padded to 3 digits (e.g. 007, 123).
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
df = pd.DataFrame({
't': pd.date_range('2025-06-01 12:00:00', periods=12, freq='117ms'),
})
df['value'] = range(len(df))
df
# Milliseconds only
ggplot(df, aes('t', 'value')) + geom_point() + ggsize(700, 250) \
+ scale_x_datetime(format='%f')
# Seconds + milliseconds
ggplot(df, aes('t', 'value')) + geom_point() + ggsize(700, 250) \
+ scale_x_datetime(format='%S.%f')
# Full ISO-like timestamp with milliseconds
ggplot(df, aes('t', 'value')) + geom_point() + ggsize(700, 250) \
+ scale_x_datetime(format='%Y-%m-%dT%H:%M:%S.%f')
ggplot(df, aes('t', 'value')) + ggsize(700, 250) \
+ geom_point(tooltips=layer_tooltips()
.format('^x', '%H:%M:%S.%f')
.line('t|^x')
.line('value|^y')) \
+ scale_x_datetime(format='%S.%f')