Nixtla / utilsforecast

https://nixtlaverse.nixtla.io/utilsforecast
Apache License 2.0
42 stars 7 forks source link

`plot_series` function adding dates that don't exist in dataset #124

Closed MMenchero closed 3 weeks ago

MMenchero commented 3 weeks ago

What happened + What you expected to happen

The plot_series function is adding additional dates that don't exist in the dataset. See reproducible example below.

Versions / Dependencies

Version 0.2.5

Reproducible example

import pandas as pd 
from utilsforecast.plotting import plot_series

algeria_economy = pd.read_csv('https://nixtla-public.s3.amazonaws.com/fpp4-datasets/algeria_exports.csv', parse_dates=['ds'])
plot_series(algeria_economy)

The plot starts on 1950, but the earliest date in the dataset is 1960-12-31.

Screenshot 2024-09-17 at 20 11 15

Issue Severity

High: It blocks me from completing my task.

AzulGarza commented 3 weeks ago

@jmoralez wdyt?

jmoralez commented 3 weeks ago

Seems to be due to this https://github.com/Nixtla/utilsforecast/blob/6d06cb1285e3bf38234958c6529613012d72bb11/utilsforecast/plotting.py#L394-L399 which was added in #92. Removing that produces this plot image

Is that the expected? I guess that's there for cases when the dates have days and can be too wide

jmoralez commented 3 weeks ago

We could also go with the plots produced by pandas, which don't add any padding image

MMenchero commented 3 weeks ago

Thank you, I think the first image should be the expected result.