Skip missing data on timeseries axis

I’d like to suggest adding hvplot parameter to skip missing data on the x axis.

E.g. OHLC charts create gap for missing day “2022-08-02”:

import hvplot.pandas
import pandas as pd

data = pd.DataFrame(
    {
        "Open": [100.00, 101.25, 102.75],
        "High": [104.10, 105.50, 110.00],
        "Low": [94.00, 97.10, 99.20],
        "Close": [101.15, 99.70, 109.50],
        "Volume": [10012, 5000, 18000],
    },
    index=[
        pd.Timestamp("2022-08-01"),
        pd.Timestamp("2022-08-03"),
        pd.Timestamp("2022-08-04"),
    ],
)

df = pd.DataFrame(data)

ohlc = df.hvplot.ohlc(width=300, height=200)
ohlc

I found work-around, but there is too much work, to fix x-axis, but in some cases, the numbers occurs in the x-axis labels:

df = df.reset_index(names="Date")
df["Idx"] = pd.RangeIndex(0, df.shape[0], 1)

ohlc = df.hvplot.ohlc(
    x="Idx", y=["Open", "High", "Low", "Close"], width=300, height=200
)

# fix x tick labels ------
import holoviews as hv
from bokeh.io import show

fig = hv.render(ohlc)
fig.xaxis.major_label_overrides = {
    i: dt.strftime("%b %d") for i, dt in enumerate(df["Date"])
}
# fix x tick labels ------

show(fig)

obrazek

Could there be a parameter called eg skip_missing_data to take care of this? And I would call just:

df.ohlc(skip_missing_data=True)

I found some solutions:

but neither is easy to do with hvplot.

Why I must manually change the dataframe data source (convert datetime to string) like fig.xaxis.major_label_overrides when I want only to skip the missing datetime parts.

i’m pretty sure there must be some datetime range generator that takes care of plotting the points correctly on the graph. unfortunately I have no idea if it is javascript or python. I don’t know much about the DatetimeTickFormatter code but I believe it will not be difficult to filter the missing dates there.

Hi thanks for reporting this. Can you submit an issue on hvPlot if there isn’t one already?

Ok, there is Skip missing data on timeseries axis (candlestick or in general for timeseries charts) · Issue #1458 · holoviz/hvplot · GitHub, but…

I’m not sure, if it is a hvplot problem. I think it should be implemented in bokeh and after that it can be implemented in holoviews and hvplot as a parameter.