Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot for trailing 12 months #29

Open
bhargavkakadiya opened this issue Jan 9, 2024 · 6 comments
Open

plot for trailing 12 months #29

bhargavkakadiya opened this issue Jan 9, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@bhargavkakadiya
Copy link

bhargavkakadiya commented Jan 9, 2024

Is it possible to have plot combining two different years for use case such as: trailing 12 months?
So w.r.t. to given Image, expected result which starts at month Feb and ends at Jan in a single row
image

@brunorosilva
Copy link
Owner

Hey @bhargavkakadiya , thanks for reaching out.

Unfortunately this is something that has been on my to-do list for a while now.

The best I can do for you is the years_as_columns=True option, which will plot horizontally but still separating the years.

import numpy as np
import pandas as pd

from plotly_calplot.calplot import calplot

# mock setup
dummy_start_date = "2022-12-01"
dummy_end_date = "2023-10-03"
dummy_df = pd.DataFrame(
    {
        "ds": pd.date_range(dummy_start_date, dummy_end_date, tz="Singapore"),
        "value": np.random.randint(
            -10,
            30,
            (pd.to_datetime(dummy_end_date) - pd.to_datetime(dummy_start_date)).days
            + 1,
        ),
    }
)

fig1 = calplot(
    dummy_df,
    x="ds",
    y="value",
    years_as_columns=True
)

fig1.show()

image

@brunorosilva
Copy link
Owner

When I end up doing the 12 month trailing plot, it will be a separate function to calplot and I'll mention this issue in the release.

@bhargavkakadiya
Copy link
Author

Thanks @brunorosilva the update and closest solution to task.
Great of see TTM plot function is coming up; would you able to share when could we expect this?
I gave it a try but I wasn't able to wrap my mind around everything with time range, labels, layout, etc

@brunorosilva
Copy link
Owner

brunorosilva commented Jan 11, 2024

I'll check it over the weekend to see if it's as easy as I'm thinking and give you an estimate.
The code is quite overwhelming and verbose, honestly this is a bit of Plotly's fault haha.

@brunorosilva brunorosilva self-assigned this Jan 12, 2024
@brunorosilva brunorosilva added the enhancement New feature or request label Jan 12, 2024
@brunorosilva
Copy link
Owner

Hey mate, I tried to work on it over the weekend but it's harder than I thought. I'll keep on working on it and give another update once it's closer to a solve.

@bhargavkakadiya
Copy link
Author

thanks for the update and trying out @brunorosilva I have moved to different representation for now and hope to see this feature and try it out soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants